-
Notifications
You must be signed in to change notification settings - Fork 7
/
docker.txt
60 lines (45 loc) · 1.3 KB
/
docker.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
https://docs.docker.com/reference/commandline/cli
-------------------
docker run -it image-spec /bin/bash
run and log into container
can do e.g.
adduser username sudo
exit
Change is not persistent
to exit without quitting container: ctrl-p ctrl-q
containers have names, long/sort IDs
docker ps
get list of containers
ps -a: show stopped ones too
docker run -d ...
run container in detached mode
docker logs shortid
show output from detached container
-f: stream the output
docker run -d -P image-spec
map ports
(runs default command in image)
--------------
fundamentals
docker commit container-id username/app:version
make container into an image
dockerfiles
FROM base-img
RUN cmd e.g. apt-get
each builds a new layer, so efficient to combine with &&
docker build -t imagename context
(context is where to look for Dockerfile and other files)
CMD default command
ENTRYPOINT like CMD but can't override, and can pass args in docker run cmd
VOLUME /myvol
EXPOSE 80 44
ports container will listen on
docker exec -it container-id bash
run command in running container
docker stop/start container
docker rm container
delete stopped container
docker rmi image-id
remove local image copy
docker push repo/name:tag
push image to docker hub