-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathdocker_commands
64 lines (42 loc) · 1.45 KB
/
docker_commands
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
61
62
63
64
Docker cli commands:
1. docker ps
2. docker ps -a
3. docker images
4. docker run -dit ubuntu
5. docker stop <container id>
6. docker start <container id>
7. docker pull <image name>
8. docker tag <docker image id> <dockerhub username>/imagename:firstimage
a) To login to container --> docker exec -it <conatiner id or name>
# docker login
give your docker hub user name and password:
9. docker push <docker hub name>/<docker image name>:firstimage
10. docker export <container name> > <container name.tar>
11. docker search
12. docker ps
13. docker kill <container name>
14. docker commit
15. docker commit <container name>
16. Docker port binding
# docker run --name nginx -d -p 8081:80 nginx
8081 --> Host port
80 --> docker container port
# docker run --name jenkins -d -p 8082:8080 jenkins/jenkins
17. Docker detached vs foreground.
# docker run -it ubuntu /bin/bash
# docker run -dit ubuntu /bin/bash
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dockerfile instructions:
1. FROM
2. RUN
3. COPY
4. CMD
5. EXPOSE
Demo:
# vi Dockerfile
FROM ubuntu
CMD [ "echo", "hello world" ]
# docker build .
# docker tag <docker image id> <dockerhub name>/<docker image name>:tag
# docker run --name test <docker image id>
Docker file refernce ---> https://docs.docker.com/reference/dockerfile/