2-1 Introduction and actual combat of docker architecture

 

 

docker run ubuntu echo hello docker

 

docker run nginx

 

 

^Croot@iZbp1berl2oy3e3vt5476fZ:~# docker run nginx
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up

View images

docker images

 

Run docker

docker run -p 8080:80 -d nginx

 

 

Can visit:

View the currently running container

docker ps

 

Create an html file

 

<html>
	<h1> Docker is fun 123</h1>
</html>

Copy the page to an images

docker cp index.html 173d54b314c1://usr/share/nginx/html

Look at the effect:

magical! ! !

 

Stop a docker container

docker stop 173d54b314c1

 

Can't access normally

 

 

Restart again

docker run -p 8080:80 -d nginx

 

Visit effect:

 

Now save that page

 

 

docker commit -m "fun hlg" a3602cc5370e

 

A new image is created at this time

 

Add a name now

docker commit -m "fun hlg" a3602cc5370e nginx-fun-hlg

 

 

Delete command:

docker rmi

View currently running

docker ps

 

Stop:

docker stop
root@iZbp1berl2oy3e3vt5476fZ:~# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                  NAMES
a3602cc5370e   nginx     "/docker-entrypoint.…"   13 minutes ago   Up 13 minutes   0.0.0.0:8080->80/tcp   jovial_kare
root@iZbp1berl2oy3e3vt5476fZ:~# docker stop a3602cc5370e
a3602cc5370e
root@iZbp1berl2oy3e3vt5476fZ:~# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
root@iZbp1berl2oy3e3vt5476fZ:~# 

View all containers

docker ps -a
root@iZbp1berl2oy3e3vt5476fZ:~# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                          PORTS     NAMES
a3602cc5370e   nginx     "/docker-entrypoint.…"   16 minutes ago   Exited (0) About a minute ago             jovial_kare
173d54b314c1   nginx     "/docker-entrypoint.…"   30 minutes ago   Exited (0) 19 minutes ago                 agitated_jennings
9d827f501f82   nginx     "/docker-entrypoint.…"   34 minutes ago   Exited (0) 33 minutes ago                 elastic_hugle
857d94349bca   nginx     "/docker-entrypoint.…"   38 minutes ago   Exited (0) 34 minutes ago                 eloquent_ganguly
fb0eb55c9b8b   ubuntu    "echo hello docker"      41 minutes ago   Exited (0) 41 minutes ago                 adoring_dirac
72d47427e376   ubuntu    "echo hello docker"      42 minutes ago   Exited (0) 42 minutes ago                 serene_wescoff
root@iZbp1berl2oy3e3vt5476fZ:~# 

delete

docker rm
root@iZbp1berl2oy3e3vt5476fZ:~# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                          PORTS     NAMES
a3602cc5370e   nginx     "/docker-entrypoint.…"   16 minutes ago   Exited (0) About a minute ago             jovial_kare
173d54b314c1   nginx     "/docker-entrypoint.…"   30 minutes ago   Exited (0) 19 minutes ago                 agitated_jennings
9d827f501f82   nginx     "/docker-entrypoint.…"   34 minutes ago   Exited (0) 33 minutes ago                 elastic_hugle
857d94349bca   nginx     "/docker-entrypoint.…"   38 minutes ago   Exited (0) 34 minutes ago                 eloquent_ganguly
fb0eb55c9b8b   ubuntu    "echo hello docker"      41 minutes ago   Exited (0) 41 minutes ago                 adoring_dirac
72d47427e376   ubuntu    "echo hello docker"      42 minutes ago   Exited (0) 42 minutes ago                 serene_wescoff
root@iZbp1berl2oy3e3vt5476fZ:~# docker rm fb0eb55c9b8b
fb0eb55c9b8b
root@iZbp1berl2oy3e3vt5476fZ:~# docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                      PORTS     NAMES
a3602cc5370e   nginx     "/docker-entrypoint.…"   18 minutes ago   Exited (0) 3 minutes ago              jovial_kare
173d54b314c1   nginx     "/docker-entrypoint.…"   33 minutes ago   Exited (0) 21 minutes ago             agitated_jennings
9d827f501f82   nginx     "/docker-entrypoint.…"   37 minutes ago   Exited (0) 35 minutes ago             elastic_hugle
857d94349bca   nginx     "/docker-entrypoint.…"   41 minutes ago   Exited (0) 37 minutes ago             eloquent_ganguly
72d47427e376   ubuntu    "echo hello docker"      44 minutes ago   Exited (0) 44 minutes ago             serene_wescoff
root@iZbp1berl2oy3e3vt5476fZ:~# 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/huanglianggu/article/details/115093477