docker pull 名称
b. 查看:html
docker image ls -a
c. 删除指定镜像:nginx
docker image rm -f 名称
d. 删除无用镜像:git
docker image prune
docker run -p 本地端口:镜像内端口 -v 本地文件:远程文件 -d(后台运行) -it(交互式运行) 镜像名
b. 启动:docker
docker container start 短名称
c. 中止:vim
docker container stop 短名称
d. 删除指定容器:centos
docker container rm -f 名称
e. 删除中止中的容器:markdown
docker container prune
mkdir -p nginx/{conf,www}
b. 建立nginx配置文件:
vim nginx/conf/nginx.confapp
daemon off; user nginx; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
c. 建立测试文件:
vim nginx/www/index.htmlcurl
hello
d. 建立Dockerfile文件:
vim Dockerfileide
FROM centos RUN yum -y install pcre-devel \ && yum -y install zlib-devel \ && yum -y install wget \ && yum -y install gcc automake autoconf libtool make \ && mkdir /data \ && cd /data \ && wget https://nginx.org/download/nginx-1.15.6.tar.gz \ && tar -xzf nginx-1.15.6.tar.gz \ && cd nginx-1.15.6 \ && ./configure \ && make \ && make install \ && useradd -s /sbin/nologin -M nginx COPY $PWD/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf COPY $PWD/nginx/www/index.html /usr/local/nginx/html/index.html CMD ["/usr/local/nginx/sbin/nginx"]
e. 建立镜像:
docker build -t test .
f. 运行:
docker run -p 80:80 -d test
g. 测试:
curl localhost