A detailed tutorial on how to install Linux Docker
- 2020-05-17 07:06:20
- OfStack
Install the mysql service
Download mysql image:
docker pull mysql
Create the mysql container and run it in the background, specifying the database password 123456. -e specifies environment variables.
docker run --name mysql_db -e MYSQL_ROOT_PASSWORD=123456 -d mysql
Use the official wordpress
wordpress mirror daocloud.io:
docker pull daocloud.io/daocloud/dao-wordpress:latest
Please login before pulling image: docker login daocloud.io (login with user name).
Or use the wordpress official image:
docker pull wordpress
Create the wordpress container application and run it in the background:
docker run --name some-wordpress --link mysql_db:mysql -p 8001:80 -d daocloud.io/daocloud/dao-wordpress
You can then access the site from your browser via http://localhost:8001 (or http:// host-ip :8001).
If you want to use an external database, you can set the connection mode of the corresponding database through the above environment variables:
$ docker run --name some-wordpress -e WORDPRESS_DB_HOST=10.1.2.3:3306 \
-e WORDPRESS_DB_USER=... -e WORDPRESS_DB_PASSWORD=... -d wordpress
More environmental variables:
WORDPRESS_DB_HOST database host address (default is IP and port 3306 of its link mysql container: :3306)
WORDPRESS_DB_USER database user name (root by default)
WORDPRESS_DB_PASSWORD database password (default is the value of the MYSQL_ROOT_PASSWORD variable supplied by its link mysql container)
WORDPRESS_DB_NAME database name (wordpress by default)
WORDPRESS_TABLE_PREFIX database table name prefix (default is empty, you can override the configuration in wp-config.php from this variable)
Security correlation (default is random SHA1)
WORDPRESS_AUTH_KEY
WORDPRESS_SECURE_AUTH_KEY
WORDPRESS_LOGGED_IN_KEY
WORDPRESS_NONCE_KEY
WORDPRESS_AUTH_SALT
WORDPRESS_SECURE_AUTH_SALT
WORDPRESS_LOGGED_IN_SALT
WORDPRESS_NONCE_SALT
If the database specified by the WORDPRESS_DB_NAME variable does not exist, then the wordpress container will automatically attempt to create the database at startup, but the user specified by the WORDPRESS_DB_USER variable will need the permission to create the database.
Dockerfile warehouse: https: / / github com/docker - library/wordpress
Choreographed using Fig
Fig is the application orchestration tool of Docker, which is mainly used to build complex applications based on Docker together with Docker 1. Fig manages multiple Docker containers through one configuration file, which is very suitable for the scenario of combining multiple containers for development. Currently, Fig has been upgraded and renamed Compose. Compose backwards compatible with Fig.
The Docker application management is made easier and faster by the application orchestration tool. Fig website: http: / / www fig. sh /
Install Fig:
# methods 1 :
curl -L https://github.com/docker/fig/releases/download/1.0.1/fig-`uname
-s`-`uname -m` > /usr/local/bin/fig; chmod +x /usr/local/bin/fig
# methods 2 :
yum install python-pip python-dev
pip install -U fig
Write fig. yml:
wordpress:
image: daocloud.io/daocloud/dao-wordpress:latest
links:
- db:mysql
ports:
- "8002:80"
db:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=123456
Deployment application:
# Start the
fig up
# Get up and running in the background
fig up -d
You can then access the site from your browser via http://localhost:8002 (or http:// host-ip :8002).
fig logs See the log
fig port View port mapping
Use the network
wordpress:
image: daocloud.io/daocloud/dao-wordpress:latest
environment:
- WORDPRESS_DB_HOST=119.119.192.246:3306
- WORDPRESS_DB_USER=root
- WORDPRESS_DB_PASSWORD=123456
ports:
- "80"
Fig command:
docker run --name mysql_db -e MYSQL_ROOT_PASSWORD=123456 -d mysql
0
Note: fig has been upgraded to compose: https: / / github com/docker/compose
The batch
docker run --name mysql_db -e MYSQL_ROOT_PASSWORD=123456 -d mysql
1
The above is the site to introduce you Linux Docker installation of wordpress method detailed tutorial, I hope to help you, if you have any questions welcome to give me a message, this site will timely reply to you.