2.bind mounts
docker run -d --name=nginx-4 --mount type=bind, src=/root/docker(宿主机目录),dst=/usr/share/nginx/html nginx (不会拿容器种的数据)
3.tmpfs 不希望数据持久存储提高写入性能,几乎不用
三.网络模式:
-net=bridge默认桥接网络
docker run -it --net=host busybox(宿主机相同)
--net=none(不会进行网络配置,需要手动配置)
--net container:bs 某个应用加入到bs网络中(具有相同的网络,其他隔离)
自定义网络(自定义保持容器互通互通)
docker network create bs-net
docker run -it --name bs1 --net bs-net busybox
docker run -it --name bs2 --net bs-net busybox
四.容器网络访问原理
veth配对通道
iptables -nvL 地址转换实现
外到内 --eth0--dnat-->docker0--veth0-veth1
五.Dockerfile
FROM centos:latest
MAINTAINER rolin
RUN yum install gcc -y
COPY run.sh /usr/bin
EXPOSE 80
CMD ["run.sh"]
docker build -t -f
demo1:lnmp
1.自定义网络
docker network create lnmp
2.创建mysql容器
docker run -d --name lnmp_mysql --net lnmp --mount src=mysql-vol,dst=/var/lib/mysql -e \
MYSQL_ROOT_PASSWORD=123 -e MYSQL_DATABASE=wordpress mysql:5.7 --character-set-server=utf8
3.创建php容器
docker run -d --name lnmp_php --net lnmp --mount src=wwwroot,dst=/wwwroot php:v1
4.创建nginx容器
docker run -d --name lnmp_nginx --net lnmp -p 88:80 \
--mount type=bind,src=$(pwd)/
5.以wordpress博客为例
六.harbor
https://blog.csdn.net/weixin_48007336/article/details/107631338 (注意如果没有用https的情况,需要在客户端/etc/docker/daemon.json添加{ "insecure-registries":["xx.xx.xx.xx"] })
原文:https://blog.51cto.com/luoguoling/2537365