首页 > 其他 > 详细

Docker

时间:2021-01-29 10:01:09      阅读:28      评论:0      收藏:0      [点我收藏+]

docker 从入门到放弃

简单的nginx容器

  • [x] Dockerfile
tee Dockerfile <<-‘EOF‘
FROM ubuntu:18.04
LABEL maintainer="james@example.com"
ENV REFRESHED_AT 2014-06-01

RUN apt-get -qq update && apt-get -qq install nginx

RUN mkdir -p /var/www/html/website
ADD nginx/global.conf /etc/nginx/conf.d/
ADD nginx/nginx.conf /etc/nginx/

EXPOSE 80
EOF
  • [x] nginx.conf
tee nginx.conf <<-‘EOF‘
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;

events {  }

http {
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;
  gzip on;
  gzip_disable "msie6";
  include /etc/nginx/conf.d/*.conf;
}
EOF
  • [ ] global.conf
tee global.conf <<-‘EOF‘
server {
        listen          0.0.0.0:80;
        server_name     _;

        root            /var/www/html/website;
        index           index.html index.htm;

        access_log      /var/log/nginx/default_access.log;
        error_log       /var/log/nginx/default_error.log;
}
EOF
  • [x] index.html
tee index.html <<-‘EOF‘
<head>

<title>Test website</title>

</head>

<body>

<h1>This is a test website</h1>

</body>
EOF
docker build -t whalefall541/nginx .

 docker run -d -p 80 --name website -v $PWD/website:/var/www/html/website:rw whalefall541/nginx:v1 nginx

如何删除垃圾镜像

清理docker镜像

参考资料:

  1. 书籍 The Docker Book
  2. 博客 清理docker镜像

Docker

原文:https://www.cnblogs.com/whalefall541/p/14342689.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!