In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What is Docker Compose, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Introduce a very important tool-Docker Compose, which is often used.
Let's start with a case study of why we use Docker Compose.
Case study: how to deploy a WordPress through a container?
Now pull the WordPress locally:
Docker pull wordpressdocker image lsREPOSITORY TAG IMAGE ID CREATED SIZEvincent/my-nginx latest e3e9c5946773 23 hours ago 109MBwordpress latest a541a1a59631 41 hours ago 447MBvincent/flask-redis latest 31b9d9c546b0 3 days ago 919MBvincent/ubuntu-base latest 68941b82b183 4 days ago 557MBubuntu 16.04 13c9f1285025 2 weeks ago 119MBredis latest 3c41ce05add9 3 weeks ago 95MBpython 2.7 37093962fbf5 3 weeks ago 914MBnginx latest 719cd2e3ed04 3 weeks ago 109MBmysql latest c7109f74d339 3 weeks ago 443MBhello-world latest fce289e99eb9 6 months ago 1.84kB
Mysql is already available locally, so there is no need to pull it.
Create a mysql container:
We need to set a root password for mysql. How to set it? You can see the introduction to mysql on docker hub. Use-e MYSQL_ROOT_PASSWORD=123456 and create a database wordpress,-e MYSQL_DATABASE=wordpress while starting the container
Why not apply the-p parameter? Because our database is not accessed by outsiders, but by wordpress. So the order is as follows:
Docker run-d-- name mysql- v mysql-data:/var/lib/mysql-e MYSQL_ROOT_PASSWORD=123456-e MYSQL_DATABASE=wordpress mysqldocker container lsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESfc99f5a686a1 mysql "docker-entrypoint.s …" 21 seconds ago Up 20 seconds 3306/tcp, 33060/tcp mysql
The mysql8.0 version will encounter the following problem:
The server requested authentication method unknown to the clientmysqli_real_connect (): The server requested authentication method unknown to the client [caching_sha2_password] mysqli_real_connect (): (HY000/2054): The server requested authentication method unknown to the client
The solution is:
Mysql > ALTER USER root IDENTIFIED WITH mysql_native_password BY 'PASSWORD';Query OK, 0 rows affected (0.08 sec)
Just restart wordpress.
Create a wordpress container:
The configuration parameters for wordpress can also be seen on docker hub. The command is as follows:
Docker run-d-e WORDPRESS_DB_HOST=mysql:3306-e WORDPRESS_DB_USER=root-e WORDPRESS_DB_PASSWORD=123456-- link mysql-p 808080purl 80 wordpress
View the container:
Ocker container lsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESaa6ae7b0795b wordpress "docker-entrypoint.s..." 4 seconds ago Up 3 seconds 0.0.0.0 80/tcp jolly_zhukovskyfc99f5a686a1 mysql 8080-> 80/tcp jolly_zhukovskyfc99f5a686a1 mysql "docker-entrypoint.s …" 4 minutes ago Up 4 minutes 3306/tcp, 33060/tcp mysql
Then visit 127.0.0.1purl 8080 and the following page appears:
Indicates that the installation was successful.
We launched a wordpress application with two docker container, a process similar to our previous process of linking redis with Python flask.
Similar to this, many modules and containers are interdependent, creating, modifying, deleting and other management operations are very inconvenient. Hope to put all these write dependencies into a group to manage together. So docker Compose came into being.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.