1、docker build -t register_url/namespace/csphere/centos:lastest 根据Dockerfile构建镜像
2、docker images 显示镜像的大小
3、通过docker 镜像 生成docker容器 docker run -it 交互启动 -d 后端启动 -大P 2222:22 宿主机将端口(下次启动时端口随机生成)替换为容器22 -p 2222:22创建2222来隐射docker 22 --name "name" csphere/centos:7.1 镜像
sky@ubuntu:/opt/program/docker-training/centos7$ sudo docker run -d -p 2222:22 --name base csphere/centos:7.172b407bc822c61d13b95082aa732bf1a8535a118c646273845813c473612d5ce
4、进入docker
sky@ubuntu:/opt/program/docker-training/php-fpm$ sudo docker exec -it website /bin/bash[root@c5cc1d4aa35f /]#
5、删除镜像
sky@ubuntu:/opt/program/docker-training/mysql$ sudo docker rm dbserverError response from daemon: You cannot remove a running container 39d71dec5b640cf409c36077caef4c132b4547fa8941b0c05f3da15eef2f7d1e. Stop the container before attempting removal or force removesky@ubuntu:/opt/program/docker-training/mysql$ sky@ubuntu:/opt/program/docker-training/mysql$ sudo docker rm -f dbserverdbserver
6、参数输入:
docker run -d -p 3306:3306 -v host_dir:container_dir==》sky@ubuntu:/opt/program/docker-training/mysql$ sudo docker run -d -p 3306:3306 -v /var/lib/docker/vfs/dir/mydata:/var/lib/mysql csphere/mysql:5.539d5fab1865b76d12cdf78ac13fe256ac2ab844953aee15f1734f43c1e165900
7、映射文件路径后查看(重新挂载后文件还在)
sky@ubuntu:/opt/program/docker-training/mysql$ cd /var/lib/docker/vfs/dir/mydata/sky@ubuntu:/var/lib/docker/vfs/dir/mydata$ lsaria_log.00000001 ibdata1 ib_logfile1 mysql performance_schemaaria_log_control ib_logfile0 mydb mysql.sock test
8、停止docker容器
sky@ubuntu:/var/lib/docker/vfs/dir/mydata$sudo docker stop 39d
9、删除docker
sky@ubuntu:/var/lib/docker/vfs/dir/mydata$sudo docker rm 39d
10、添加变量
sky@ubuntu:/opt/program/docker-training/wordpress$ docker run -d -p 80:80 --name wordpress -e WORDPRESS_DB_HOST=192.168.31.129 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=root csphere/wordpress:4.2
11、启动elk
sudo docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -p 9300:9300 -v /opt/program/dockerconf/elasticsearch/data:/var/lib/elasticsearch -v /opt/program/dockerconf/elasticsearch/config/jvm.options:/etc/elasticsearch/jvm.options -v /opt/program/dockerconf/elasticsearch/config/elasticsearch.yml:/etc/elasticsearch/elasticsearch.yml --name elk sebp/elk
12、启动mongo
docker run -p 27017:27017 -v $PWD/db:/data/db -d mongo:3.2
docker run -it mongo:3.2 mongo --host 172.17.0.1