Docker Tutorial Student Notes

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值