上文说到docker的安装,如果你已经成功安装docker,那么就来看下docker的使用吧!
Docker容器:由docker的镜像(images)创建docker容器,所以,我们首先需要一个docker镜像
docker_images
本文以nginx_image为例
1:查询可用nginx_image
[root@www ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 10461 [OK]
jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 1480 [OK]
richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 657 [OK]
jrcs/letsencrypt-nginx-proxy-companion LetsEncrypt container to use with nginx as p… 449 [OK]
...
2:下拉image,选择第一个并执行docker pull
[root@www ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a5a6f2f73cd8: Pull complete
1ba02017c4b2: Pull complete
33b176c904de: Pull complete
Digest: sha256:5d32f60db294b5deb55d078cd4feb410ad88e6fe77500c87d3970eca97f54dba
Status: Downloaded newer image for nginx:latest
[root@www ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 568c4670fa80 7 days ago 109MB
创建docker容器
1:创建
[root@www ~]# docker create nginx
b716fa0296d244c6a779c3d488eb06a6e6157c2c20e280ceef82ec91d740a32a
上面显示的数字为容器的ID