-
Notifications
You must be signed in to change notification settings - Fork 0
/
DockerCommandNotes.txt
42 lines (30 loc) · 1.15 KB
/
DockerCommandNotes.txt
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
36
37
38
39
40
41
42
Notes for Docker
______________________________________________________________________
*** Docker build ***
* Docker build
(navigate to folder with dockerfile)
docker build .
* Docker build with custom dockerfile (e.g. Dockerfile.dev)
docker build -f Dockerfile.dev .
______________________________________________________________________
*** Docker run ***
* Docker run
docker run imagename
* Docker run with arguments (e.g. "ping google.com")
docker run imagename ping google.com
* Docker run with port binding
docker run -p 3000:3000 imagename
(Local PC port:Container port)
* Docker run with attached input from terminal
docker run -it imagename
* Docker run with volumes
docker run -p 3000:3000 -v /app/node_modules -v ${pwd}:/app imagename
(first -v : Bind folder in container)
(second -v : Bind folder outside container)
(Use $(pwd) instead of ${pwd} in bash)
______________________________________________________________________
*** Docker exec ***
* Docker exec (attach to running container and execute arguments (e.g. "ping google.com"))
docker exec -it containername ping google.com
* Docker exec with attached shell
docker exec -it containername sh