PrerequisitesCompose is a tool for orchestrating Docker containers. It is a powerful tool for integrating and publishing Docker applications. It can define and run multi-container applications. In Compose, you can use YAML files to configure your application services. Then, with just one simple command, all the services you configured are created and started. Docker-compose is based on Docker, so we need to install Docker before we can use Docker-compose. Using Compose basically involves the following three steps: Define your application environment in Dockerfile, which can be multiple docker applications. Reference URL: Docker installation
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 sudo yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
yum install https://download.docker.com/linux/fedora/30/x86_64/stable/Packages/containerd.io-1.2.6-3.3.fc30.x86_64.rpm
docker --version
docker-compose installationThe official website download address may be slow, it is recommended to use the following
curl -L https://get.daocloud.io/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose version
Getting Started with Docker ComposeGenerate mysql and redis containers through docker-compose 1. Create a project directory and enter $ mkdir composetest $ cd composetest 2. Create a The specific contents of the file are as follows: version: "3.0" services: mysqldb: image:mysql:5.7.19 container_name: mysql ports: - "3306:3306" volumes: - /root/mysql/conf:/etc/mysql/conf.d - /root/mysql/logs:/logs - /root/mysql/data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: root networks: -ems depends_on: - redis redis: image: redis:4.0.14 container_name: redis ports: - "6379:6379" networks: -ems volumes: - /root/redis/data:/data command: redis-server networks: ems: 3. Start Start in current folder
The output log is as follows Check whether the container in Docker is availableCheck whether the container is generated Test whether the redis container is available Test whether the mysql container is available
Summarize1. The docker-compose command cannot be executed because of a permission issue. We need to open permissions and execute the following command chmod +x /usr/local/bin/docker-compose 2. During the study period, we can use docker-compose in the virtual machine to build our basic hardware facilities, which is very convenient and saves a lot of time in configuring the environment and installing basic services. 3. Docker-compose still needs to be learned Reference URL:
This is the end of this article about getting started with docker compose helloworld. For more information about getting started with docker compose helloworld, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Master-slave synchronization configuration of Mysql database
>>: Solution to span width not being determined in Firefox or IE
1. Install tomcat8 with docker 1. Find the tomcat...
What is wxs? wxs (WeiXin Script) is a scripting l...
These two attributes are often used, but their di...
Preface In this article, we'll explore the ev...
1. I downloaded QT5.13 version before, but after ...
Table of contents 1. What is DOM 2. Select elemen...
Chinese characters cannot be input in lower versio...
Table of contents 1. Title 2. Code 3. Results IV....
We often see a cool effect where the mouse hovers...
1. Create users and authorize Creating users and ...
Table of contents 1. Introduce cases 2. View the ...
Image tag : <img> To insert an image into a ...
This article example shares the specific code of ...
All websites, whether official, e-commerce, socia...
Table of contents 1. Create a sql script file con...