Last update at :2024-05-17,Edit by888u
Docker is a containerization platform that lets you quickly build, test, and deploy applications as portable, self-sufficient containers that can run almost anywhere. Docker Compose is a tool that allows us to customize and orchestrate multi-container Docker applications. It uses YAML files to configure the application's containers, networks, and volumes.
Compose can be used for a variety of purposes. Single-host application deployment, automated testing, and local development are the most popular use cases for Docker Compose. This article will introduce how to install the latest version of Docker Compose on Debian 10 Buster. Includes basic applications.
First, basic conditions
Before continuing, please make sure you have met the following prerequisites:
1. We have server management rights, such as root rights.
2. Docker has been installed on our server. If it is not installed, you need to install it.
Second, install Docker Compose on Debian10
The Docker Compose installation package is available in the official Debian 10 repository, but it may not always be the latest version. The recommended method is to install Docker Compose from Docker's GitHub repository.
The latest stable version of Docker Compose is version 1.23.1. Before downloading the Compose files, visit the Compose repository releases page on GitHub and check if new versions are available for download.
Address: https://github.com/docker/compose/releases
Use the following steps to install the latest version of Docker Compose on Debian 10.
1. Use wget or curl to download the Docker Compose binary file to the /usr/local/bin directory:
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr /local/bin/docker-compose
2. Authorization permissions
sudo chmod +x /usr/local/bin/docker-compose
3. Verification version
docker-compose --version
See the output:
docker-compose version 1.23.1, build b02f1306
Third, getting started with Docker Compose
Here, we give a simple example to show how to use Docker Compose to set up a local WordPress development environment.
1. Create a directory
mkdir wordpress_app && cd wordpress_app
2. Create files
nano docker-compose.yml
Paste code:
version: '3.7' services: db: image: mysql:8.0 command: --default-authentication-plugin=mysql_native_password restart: always volumes: -db_data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: wordpress wordpress: image: wordpress restart: always volumes: - ./wp_data:/var/www/html ports: - "8080:80" environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: root WORDPRESS_DB_PASSWORD: password depends_on: -db volumes: db_data: wp_data:
From the project directory, start WordPress by running the following command.
docker-compose up
We can see the output:
... ] /usr/sbin/mysqld: ready for connections. Version: '8.0.18' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL. db_1_99946702ac7e | 2019-12-15T21:37:29.109255Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: ': :' port: 33060 ...
Docker Compose will pull the image, start the container, and create the wp_data directory in your project directory. Enter http://0.0.0.0:8080/ in the browser and we can see the standard WordPress installation wizard.
We can see that these commands are available.
1. Stop
CTRL+C
2. Use the -d option to start Compose in detached mode
docker-compose up -d
3. To view the running docker container, please use the following command
docker-compose ps
4. To stop the service when Compose is running in detached mode, use:
docker-compose stop
5. If you want to completely delete the container, please use the down option:
docker-compose down
Fourth, uninstall Docker Compose
If we need to uninstall Docker Compose.
sudo rm /usr/local/bin/docker-compose
It’s that simple, have we learned how to install Docker Compose on Debian again.
Recommended site searches: domain name and host, 30-day virtual host trial, permanent free Linux server, network server rental, free php space application, Korean virtual host, IP reverse domain name check, foreign host purchasing agency, website space provider, fast website Filing,
发表评论