forked from AntoDevOps-Github/Devops-Clarification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocker commands.txt
105 lines (69 loc) · 3.16 KB
/
Docker commands.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
docker info
docker search centos
docker run -it centos bin/bash
docker commit -m "What did you do to the image" -a "Author Name" container-id repository/new_image_name
docker commit -m "added maria nd git" -a "pandian" e8e285951825 dockerpandian/centos-mariadb:v1
docker images
docker login -u dockerpandian
docker exec -it <CONTAINER ID > bin/bash
docker build -t dir_containing_dockerfile . # Create image using this directory's Dockerfile
docker run -p 4000:80 container_name # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker ps # See a list of all running containers
docker stop <hash> # Gracefully stop the specified container
docker ps -a # See a list of all containers, even the ones not running
docker kill <hash> # Force shutdown of the specified container
docker rm <hash> # Remove the specified container from this machine
docker rm $(docker ps -a -q) # Remove all containers from this machine
docker images -a # Show all images on this machine
docker rmi <imagename> # Remove the specified image from this machine
docker rmi $(docker images -q) # Remove all images from this machine
docker login # Log in this CLI session using your Docker credentials
docker tag <imageID> username/repository:tag # Tag <image> for upload to registry
docker push username/repository:tag # Upload tagged image to registry
docker run username/repository:tag # Run image from a registry
docker inspect <container-id>
docker export loving_morse > mybuild4.tar
docker import mybuild4.tar mybuild:importv5
docker login --username=dockerpandian
# This is Dockerfile first batch
FROM centos:6
LABEL maintainer="SLA"
RUN yum update -y && yum install -y httpd net-tools
RUN mkdir -p /run/httpd
RUN rm -rf /run/http/* /tmp/httpd/*
CMD echo "Remember to check your container IP Address"
ENV ENVIROMENT="devops batch"
EXPOSE 80
ENTRYPOINT apachectl ".DFOREGROUND"
:wq
**************************************************
docker build -t devopsclass:v3
docker run -d --name web1 --rm devopsclass:v3
docker ps
docker run -d --rm --name testweb1 devopsclass:v3
********************************************************
# This is Dockerfile batch
ARG TAGVERSION=6
FROM centos:${TAGVERSION}
LABEL maintainer="SLA"
RUN yum update -y && \
yum install -y httpd net-tools && \
mkdir -p /run/httpd && \
rm -rf /run/http/* /tmp/httpd/*
COPY index.html /var/www/html/
ENV ENVIROMENT="devops batch"
VOLUME /mymount
EXPOSE 80
ENTRYPOINT ls -al / | wc -l
:wq
echo "This is our Docker Image HTML index file" > index.html
docker build -t mybuild:v4 .
docker run mybuild:v4
*************************************************
docker ps -a --no-trunc
docker image history mybuild:v4
cd /var/lib/docker
******************************************************
docker export loving_morse > mybuild4.tar
docker import mybuild4.tar mybuild:importv5