“How to Install Docker” “Compose on Ubuntu 20.04”
We hope this post helped you to find out “How to Install Docker” “Compose on Ubuntu 20.04”
Docker Compose is a command-line device that means that you can outline and orchestrate multi-container Docker functions. It makes use of a YAML file to configure the appliance’s companies, networks, and volumes.
With Compose, you may outline a transportable utility setting you could run on any system. Compose environments are remoted from one another, permitting you to run a number of copies of the identical setting on a single host.
Compose is usually used for native growth, single host utility deployments, and automatic testing.
This text explains how you can set up the most recent model of Docker Compose on Ubuntu 20.04. We’ll additionally discover the essential Docker Compose ideas and instructions.
We’re assuming that you’ve Docker put in in your Ubuntu machine.
Installing in Docker Compose on Ubuntu #
Docker Compose is a single binary file. The set up is simple. We’ll obtain the file to a listing that’s within the system PATH and make it executable.
The Docker Compose package deal is accessible within the official Ubuntu 20.04 repositories, however it could not at all times be the most recent model.
On the time of writing this text, the most recent secure model of Docker Compose is
1.25.5. Earlier than downloading the Compose binary, go to the Compose repository release page on GitHub and verify if there’s a new model accessible for obtain.
curl to download the Compose file into the
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Once the download is complete, apply executable permissions to the file:
sudo chmod +x /usr/local/bin/docker-compose
To verify that the installation was successful, run the following command which will print the Compose version:
The output will look something like this:
docker-compose version 1.25.5, build b02f1306
That’s it! Docker Compose has been put in in your Ubuntu machine, and you can begin utilizing it.
Getting Began with Docker Compose #
On this part, we’ll use Docker Compose to construct a multi-container WordPress utility
Step one is to create a undertaking listing:
Open your text editor and create a file called
docker-compose.yml inside the project directory:
Paste the following content:
version: '3' services: db: image: mysql:5.7 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:
Let’s analyze the construction of the
Subsequent, you outline companies, volumes and networks.
On this instance, we’ve got companies,
wordpress. Every service runs one picture, and creates a separate container when docker-compose is run.
Companies can use photographs which might be accessible on DockerHub or photographs constructed from the Dockerfile. The service part additionally contains keys specifying uncovered ports, volumes, setting variables, dependencies, and different Docker instructions
From the undertaking listing, begin up the WordPress utility by operating the next command:
Compose will pull the pictures, begin the containers, and create the
http://0.0.0.0:8080/ in your browser, and you will note the WordPress set up display screen. At this level, the WordPress utility is up and operating and you can begin working in your theme or plugin.
To cease Compose press
It’s also possible to begin the Compose in a indifferent mode by passing the
docker-compose up -d
To check the running services use the
Name Command State Ports ---------------------------------------------------------------------------------- my_app_db_1 docker-entrypoint.sh mysqld Up 3306/tcp, 33060/tcp my_app_wordpress_1 docker-entrypoint.sh apach ... Up 0.0.0.0:8080->80/tcp
When Compose is running in detached mode to stop the services, run:
To stop and remove the application containers and networks, use the
Uninstalling Docker Compose #
To uninstall Docker Compose, simply remove the binary by typing:
sudo rm /usr/local/bin/docker-compose
We’ve proven you how you can set up Docker Compose on Ubuntu 20.04. Utilizing Docker Compose can considerably enhance your workflow and productiveness. You possibly can outline your growth setting with Docker Compose and share it with the undertaking collaborators.
We hope the “How to Install Docker” “Compose on Ubuntu 20.04” help you. If you have any query regarding “How to Install Docker” “Compose on Ubuntu 20.04” drop a comment below and we will get back to you at the earliest.
We hope this post helped you to find out “How to Install Docker” “Compose on Ubuntu 20.04” . You may also want to see – How to Upgrade to Ubuntu 20.04