A, MySQL deployment
(1) Pull mirror mysql
docker pull centos/mysql-57-centos7
(2) create the container
docker run -di --name = tensquare_mysql -p 33306: 3306 -e MYSQL_ROOT_PASSWORD = password container host name
The -p port mapping, port mapping format host: port container runtime
-e Add the environment variable MYSQL_ROOT_PASSWORD on behalf of the root user's login password
E.g:
docker run -di --name=tensquare_mysql -p 33306:3306 -e MYSQL_ROOT_PASSWORD=123456 centos/mysql-57-centos7
(3) remote login mysql
Connecting the host IP, as specified port 33306
Two, tomcat deployment
(1) Mirror Pull
docker pull tomcat:7-jre7
(2) create the container
Create a container -p indicates the address mapping
docker run -di --name=mytomcat -p 9000:8080 -v /usr/local/webapps:/usr/local/tomcat/webapps tomcat
Three, Nginx deployment
(1) Mirror Pull
docker pull nginx
(2) create Nginx container
docker run -di --name=mynginx -p 80:80 nginx
The page mode AdminTLE nginx deployed to the present
1, first of all into the container mynginx in the etc directory to find the folder nginx
2, enter nginx folder, find the file nginx.conf view
3, the entry can be seen from the reference profile may be nginx.
4, into the conf.d folder to view files default.conf
5, see the directory nginx welcome page
6, into the welcome page directory
7, exit the container, AdminTLE renamed html. Html file and replace / usr / share / nginx / under folder
8、输入宿主机IP 便能看到模板页面
四、Redis部署
(1)拉取镜像
docker pull redis
(2)创建容器
docker run -di --name=myredis -p 6379:6379 redis
通过Redis windos桌面程序连接Docker内部
五、备份迁移
容器保存为镜像
我们可以通过以下命令将容器保存为镜像
docker commit 模板容器名称 新建镜像名字
查看已有镜像
镜像备份
我们可以通过以下命令将镜像保存为tar 文件
docker save -o mynginx.tar mynginx_adminlte
其中
mynginx.tar:是生成的文件格式名字。
mynginx_adminlte:是需要保存的镜像名字。
镜像恢复与迁移
首先我们先删除掉mynginx_img镜像 然后执行此命令进行恢复
docker load -i mynginx.tar
-i 输入的文件
执行后再次查看镜像,可以看到镜像已经恢复