一、docker 部署nginx 和tomcat 并管理
docker search nginx
docker pull nginx
docker ps
docker exec -it 19ba07671929 /bin/bash
--启动一个测试的nginx将配置文件复制到挂载的配置文件下边/usr/local/nginx/conf[因为docker不能挂载单个文件]
docker run --name some-nginx -d -p 8080:80 nginx
docker cp some-nginx:/etc/nginx /tmp
--docker cp /tmp some-nginx:/etc/nginx
docker run -e TZ="Asia/Shanghai" -d -p 80:80 --name nginx_web -v /usr/local/nginx/html:/usr/share/nginx/html -v /usr/local/nginx/conf/conf.d:/etc/nginx/conf.d -v /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /usr/local/nginx/logs:/var/logs/nginx nginx
docker search tomcat
docker pull tomcat
docker images
docker run -d -p 18080:8080 tomcat
docker ps
部署probe.war http://blog.itpub.net/22275400/viewspace-2645002/ tomcat-users.xml参照在源文件上改。
docker exec -it 719c0ba127a9 /bin/bash
docker cp tomcat-users.xml 719c0ba127a9:/usr/local/tomcat/conf/
docker restart unruffled_pasteur
vi Dockerfile
from tomcat
MAINTAINER genweihua@163.com
RUN rm -rf /usr/local/tomcat/webapps/*
COPY probe.war /usr/local/tomcat/webapps
COPY tomcat-users.xml /usr/local/tomcat/conf/
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
docker build -t probe:v1 .
docker run -d -p 28080:8080 probe:v1
--删除镜像
docker rmi probe:v1
---直接连接docker
vi /usr/lib/systemd/system/docker.service
/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H fd:// --containerd=/run/containerd/containerd.sock
systemctl daemon-reload
systemctl restart docker
lsof -i:2375
参考文章:https://blog.csdn.net/qq_29860591/article/details/104981765
https://www.cnblogs.com/sanduzxcvbnm/p/13182948.html
二、Docker之WARNING: IPv4 forwarding is disabled. Networking will not work.
vim /etc/sysctl.conf
#配置转发
net.ipv4.ip_forward=1
#重启服务,让配置生效
systemctl restart network
#查看是否成功,如果返回为“net.ipv4.ip_forward = 1”则表示成功
sysctl net.ipv4.ip_forward
#重启docker服务
service docker restart
#查看运行过的容器
docker ps -a
#启动gitlab 容器
docker start gitblab2
#进入gitlab容器
docker attach gitlab2