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