标签:dcoker
centos7
yum -y install docker
docker加速
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://224ac393.m.daocloud.io
4.systemctl start docker
[root@web01 ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2016-12-22 20:25:00 CST; 1 weeks 5 days ago Docs: http://docs.docker.com Main PID: 799 (docker-current) Memory: 39.1M CGroup: /system.slice/docker.service ├─ 799 /usr/bin/docker-current daemon --registry-mirror=http://224ac393.m.daocloud.io --exec-opt native.cg... └─28516 docker-proxy -proto tcp -host-ip 59.110.25.215 -host-port 88 -container-ip 192.168.0.2 -container-p..
4.拉公共的镜像
docker pull centos docker pull nginx docker save -o nginx.tar.gz nginx docker save -o centos.tar.gz centos docker load --input nginx.tar.gz docker load --input centos.tar.gz
5.启动一个nginx
docker run -d --name mynginx -p 59.110.25.215:88:80 nginx 说明:基于nginx镜像启动一个mynginx的容器 本机端口 88 端口对应容器 80 端口 浏览: 指定多个端口: docker run -d --name mynginx -p 59.110.25.215:88:80 -p 59.110.25.215:443:443 nginx
6.查看对应的端口
docker port mynginx [root@web01 ~]# docker port mynginx 80/tcp -> 59.110.25.215:88 [root@web01 ~]#
7.进入docker容器
#!/bin/bash # Use nsenter to access docker docker_in(){ NAME_ID=$1 PID=$(docker inspect -f "{{ .State.Pid }}" $NAME_ID) nsenter -t$PID -m -u -i -n -p } docker_in $1 上述的脚本就是dockerin.sh [root@web01 ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1f3d2f356995 nginx "nginx -g ‘daemon off" 18 minutes ago Up 18 minutes 443/tcp, 59.110.25.215:88->80/tcp mynginx [root@web01 ~]# bash dockerin.sh 1f3d2f356995 root@1f3d2f356995:/#
8.进入容器以后修改容器内部的东西
root@1f3d2f356995:/usr/share/nginx/html# echo "hello everyone" > index.html root@1f3d2f356995:/usr/share/nginx/html# pwd /usr/share/nginx/html root@1f3d2f356995:/usr/share/nginx/html#
本文出自 “砖家博客” 博客,请务必保留此出处http://wsxxsl.blog.51cto.com/9085838/1888718
标签:dcoker
原文地址:http://wsxxsl.blog.51cto.com/9085838/1888718