-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker
35 lines (30 loc) · 855 Bytes
/
docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Gain Bash Access to Running Container
docker exec -it {containerId} /bin/bash
## Build Docker Image (in directory with Dockerfile)
docker build -t {imageName} .
## Run docker container with port forwarding to host
## (port 8080 on the container will be exposed on port 8888 on the host)
docker run -p 127.0.0.1:8888:8080 {imageName}
# Remove all stopped containers
docker rm $(docker ps -a -q)
# Remove all <none> images
docker rmi $(docker images -f "dangling=true" -q)
# Docker Compose Example (docker-compose.yml)
version: '3'
services:
postgres:
image: postgres
ports:
- "5444:5432"
volumes:
- ./volumes/postgresql-data:/var/lib/postgresql/data
redis:
image: redis
ports:
- "6379:6379"
mongo:
image: mongo
ports:
- "27017:27017"
volumes:
- ./volumes/mongo-data:/data/db