Docker Tutorial Student Notes

张兴旺
2023-12-01

Notes

docker general

$docker version

docker search

$docker search tutorial

docker pull user_name(learn)/image_name(tutorial)

$docker pull learn/tutorial 

docker run <image_name>

The command is run INSIDE the container. When the command stops, so does the container.

$docker run learn/tutorial echo 'hahaha'

Install software INSIDE the container

  • how to set apt-mirrors INSIDE the container?
  • will the changes made by apt-get persists?
    the changes to the file system persists, yet the image will not be updated
$ docker run learn/tutorial apt-get install -y ping
Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
  iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.1 kB of archives.
After this operation, 143 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1 [56.1 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 56.1 kB in 1s (39.6 kB/s)
Selecting previously unselected package iputils-ping.
(Reading database ... 7545 files and directories currently installed.)
Unpacking iputils-ping (from .../iputils-ping_3%3a20101006-1ubuntu1_amd64.deb) ...
Setting up iputils-ping (3:20101006-1ubuntu1) ...

docker ps

$docker ps -l
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
da6f20d554c8        learn/tutorial      "apt-get install -y …"   10 minutes ago      Exited (0) 10 minutes ago                       stupefied_agnesi

$docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
da6f20d554c8        learn/tutorial      "apt-get install -y …"   10 minutes ago      Exited (0) 10 minutes ago                       stupefied_agnesi
c8a73dec1913        learn/tutorial      "echo hahaha"            14 minutes ago      Exited (0) 14 minutes ago                       intelligent_kowalevski
00fc3e2c49ef        hello-world         "/hello"                 39 minutes ago      Exited (0) 39 minutes ago                       priceless_neumann
6cbfad7e0382        hello-world         "/hello"                 46 minutes ago      Exited (0) 46 minutes ago                       strange_visvesvaraya

docker commit

$docker commit da6 # prefix long enough to identify a unique cnotainer
#如果你忘记加image名,系统会存到none/none
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              3bebc1438470        8 minutes ago       140MB
hello-world         latest              bf756fb1ae65        10 months ago       13.3kB
learn/tutorial      latest              a7876479f1aa        7 years ago         128MB

Reference

https://blog.csdn.net/BenXCN/article/details/109670558

https://www.docker.org.cn/book/docker/what-is-docker-16.html

 类似资料:

相关阅读

相关文章

相关问答