在使用Docker的时候,几乎所有的操作系统和应用程序都有现成的镜像,比如centos、debian、ubuntu、nginx、jenkins。直接docker pull 即可。
root@docker-lab:~# docker run -it centos
Unable to find image ‘centos:latest‘ locally
latest: Pulling from library/centos
a02a4930cb5d: Pull complete
Digest: sha256:38777a4106f0072649128ea4236241345a3ed21c55abbbd53bad5342549f6126
Status: Downloaded newer image for centos:latest
[root@02d010de5fe9 /]# wget
bash: wget: command not found
[root@02d010de5fe9 /]# yum install -y wget
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.neusoft.edu.cn
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
wget x86_64 1.14-18.el7 base 547 k
Transaction Summary
=============================================================================================================================================================
Install 1 Package
Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
wget-1.14-18.el7.x86_64.rpm | 547 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-18.el7.x86_64 1/1
install-info: No such file or directory for /usr/share/info/wget.info.gz
Verifying : wget-1.14-18.el7.x86_64 1/1
Installed:
wget.x86_64 0:1.14-18.el7
Complete!
[root@02d010de5fe9 /]# wget
wget: missing URL
Usage: wget [OPTION]... [URL]...
Try `wget --help‘ for more options.
root@docker-lab:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
02d010de5fe9 centos "/bin/bash" 5 minutes ago Up 5 minutes vibrant_bhabha
root@docker-lab:~# docker commit
"docker commit" requires at least 1 and at most 2 arguments.
See ‘docker commit --help‘.
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] [flags]
Create a new image from a container‘s changes
root@docker-lab:~# docker commit vibrant_bhabha centos-wget
sha256:7fe32c85b3a25ed750373af73dd808600c1e0112b96ddade85a01532cce0f2f3
root@docker-lab:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos-wget latest 7fe32c85b3a2 13 seconds ago 328MB
centos latest 1e1148e4cc2c 3 weeks ago 202MB
root@docker-lab:~# docker run -it centos-wget
[root@2e47049d7633 /]# wget
wget: missing URL
Usage: wget [OPTION]... [URL]...
Try `wget --help‘ for more options.
[root@2e47049d7633 /]#