Remember the method of setting up Docker production environment

  • 2020-11-30 08:42:51
  • OfStack

Server configuration:

The server USES the Alicloud ECS standard, common centos7 and docker environment images.

Build docker image acceleration:

docker mirror source in docker.ES15en is very slow in foreign countries, so the configuration is accelerated, daocloud acceleration address

Select linux accelerated configuration command, copy and paste execution, direct execution may have a comma error, I have encountered. The solution is to modify the ES21en.json file:


cd /etc/docker

ls

cat daemon.json

vi daemon.json

vi editor i go into edit mode and then esc type :wq exit

Mirror image pull:

wordpress+mysql+phpmyadmin are required


docker pull mysql

docker pull wordpress

phpmyadmin mirror had a few bad attempts, but this one worked


docker pull phpmyadmin/phpmyadmin

Container configuration:

Common with

docker run -i -t < IMAGE_ID > / bin/bash:

-ES59en: Standard input to the container
-t: Allocate 1 virtual terminal
/bin/bash: Execute the bash script
-ES67en: Run as a daemon (background)
-ES69en: Matches the docker container's 5000 port number to the host's 49153 to 65535 port by default
-p < HOT_PORT > : < CONTAINER_PORT > : Specifies the port number ql container generation
- name name
--link links to other containers


docker run -it --name myblogsql -e MYSQL_ROOT_PASSWORD=mysqlpwd -d mysql

The wordpress container configuration is associated with the mysql container mapping port 80 for external services


docker run -it --name mywordpress --link myblogsql:mysql -p 80:80 -d wordpress

Here you can access http:// public network ip/ install wordpress. If access is not possible, the server can configure port 80 for the security group.

Configuration phpmyadmin

Map port 8080 of host to port 80 of the container
2. The associated mysql
3. Set the environment variable mysql. The password entered by the user named root is the password of root

docker run -it --name myphpmyadmin -e MYSQL_USERNAME=root --link myblogsql:db -p 8080:80 -d phpmyadmin/phpmyadmin

Conclusion:

In practice, wordpress and mysql are well configured. When configuring phpmyadmin, the connection needs to specify the alias db. Not specifying it will cause an error, and both the phpmyadmin configuration file and hosts will be useless.


Related articles: