docker视频笔记-csphere

拉取测试代码

git clone https://git.oschina.net/chunjian.feng/docker-training.git

build

docker build -t csphere/centos:7.1 .
docker build -t csphere/php-fpm:5.4 .
docker build -t csphere/mysql:5.5 .
docker build -t csphere/wordpress:4.2 ./wordpress/
  Dockerfile非当前目录的情况

run

docker run -d -p 2222:22 --name base csphere/centos:7.1
docker run -d -p 8080:80 --name website csphere/php-fpm:5.4
docker run -d -p 3306:3306 --name dbserver csphere/mysql:5.5
docker run -d -p 3306:3306 -v /var/lib/docker/vfs/dir/mydata:/var/lib/mysql --name dbserver csphere/mysql:5.5
  绑定本地目录需执行:chcon -Rt svirt_sandbox_file_t /var/lib/docker/vfs/dir/mydata
docker run -d -p 80:80 --name wordpress -e WORDPRESS_DB_HOST=192.168.29.131 -e WORDPRESS_DB_USER=admin -e WORDPRESS_DB_PASSWORD=csphere2015 csphere/wordpress:4.2
  firewalld不可关闭
  宿主机打开端口限制:firewall-cmd --zone=public --add-port=3306/tcp --permanent
  firewall-cmd --reload

进入docker容器

docker exec -it website /bin/bash
docker exec -it dbserver /bin/bash

其他

docker images
docker ps -a
docker rm -f dbserver
docker stop 0b60b43a5921
docker rm 0b60b43a5921
docker logs wordpress
docker rmi b06e2fbeb5b2
docker rmi csphere/cmd:0.1

测试CMD

vim Dockerfile
  FROM docker.io/centos:centos7.1.1503
  CMD ["/bin/echo", "This is test cmd"]
docker build -t csphere/cmd:0.1 .
docker run -it csphere/cmd:0.1
docker run -it csphere/cmd:0.1 /bin/bash

测试entrypoint

vim Dockerfile
FROM docker.io/centos:centos7.1.1503
ENTRYPOINT ["/bin/echo", "This is test entrypoint"]
docker build -t csphere/ent:0.1 .
docker run -it csphere/ent:0.1
docker run -it csphere/ent:0.1 /bin/bash
docker run -it --entrypoint=/bin/bash csphere/ent:0.1

git提交

git add *
git commit -m ""
git commit -m "test cmd/entrypoint"
git push origin master

视频

第一节:Docker实战之入门以及Dockerfile
http://edu.51cto.com/center/course/lesson/index?id=71317

参考文档

CentOS7中Docker文件挂载,容器中没有执行权限
http://www.linuxidc.com/Linux/2015-03/115124.htm
CentOS7使用firewalld打开关闭防火墙与端口
http://www.cnblogs.com/moxiaoan/p/5683743.html

你可能感兴趣的:(docker视频笔记-csphere)