curl -sSL https://get.daocloud.io/docker | sh
sudo docker -d &
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=http://60026668.m.daocloud.io\"" | sudo tee -a /etc/default/docker
sudo service docker restart
Docker Container连接
-
构建Docker镜像,服务名称:spring:server Dockerfile路径:.
docker build -t spring:server .
-
启动服务spring:server,服务名:spring_server
docker run -d --name spring_server spring:server
-
启动新容器ubuntu:12.04,连接服务,(映射别名:server)
docker run -i -t --link spring_server:server ubuntu:12.04 /bin/bash
-
查看环境变量
env
服务spring:server的环境变量以(别名server)SERVER开始。
Docker 网络
-
host
docker run --net host --name spring_s1 -i -t spring:v1
- EXPOSE
Dockerifle:
EXPOSE 9000:9000 80:80
配合命令
docker run -p 9000:9000 -p 80:80 C:latest
ctrl+p+q : quietly quit
ctrl+c : exit, stop the container and exit
docker ps -a -q