Wednesday , July 24 2019
Home / Uncategorized / How to install and use Docker Compose on Ubuntu 18.04

How to install and use Docker Compose on Ubuntu 18.04



Docker Compose is a tool that allows you to define and manage multi-container Docker applications. Use a YAML file to configure the services, networks and application volumes.

Componi can be used for different purposes. Deployments of single host applications, automated testing and local development are the most popular use cases for Docker Compose.

In this tutorial we will show you how to install the latest version of Docker Compose on Ubuntu 18.04 and explore the basic concepts and commands of Docker Compose.

Prerequisites

Make sure you have satisfied the following prerequisites before continuing with this tutorial:

Install Docker Compose on Ubuntu

The Docking Compose installation package is available in the official Ubuntu 18.04 repositories but may not always be the latest version. The recommended approach is to install Docker Compose from the Docker GitHub repository.

At the time of writing this article, the latest stable version of Docker Compose is the version 1.22.0. Before downloading the Compose installer script, visit the Compose repository release page on GitHub and see if a new version is available for download.

To install Docker Compose on Ubuntu 18.04, follow these steps:

  1. Download the Docker Compose in the / Usr / local / bin directory with the following curl command:

  2. Once the download is complete, provide the permissions that can be performed on the Compose binary:

  3. Verify the installation by typing:

    The output will be similar to this:

Advertisement

Start with Docker Compose

In this section we will show how to use Docker Compose to run a WordPress stack on your Ubuntu 18.04 machine.

Start by creating a directory for the project:

Open your text editor and create a file called mobile window-compose.yml in the directory of your project:

Paste the following content:

We analyze the code line by line.

In the first line we are specifying the version of the Compose file. There are several versions of the Compose file format with support for specific versions of Docker.

Then we are defining two services, db is wordpress. Each service performs an image and will create a separate container when the compose window is executed.

The db service:

The wordpress service:

From the project directory, start the WordPress application by running the following command:

The output should be similar to this:

Compose will extract both images, start two containers and create the wp_data directory in the project directory.

Enter http://0.0.0.0:8080/ in your browser and you will see the WordPress installation screen.

From here you can start developing your WordPress theme or plugin.

To stop Compose, press CTRL + C.

You can also start Compose in independent mode by passing the -d flag.

To check the services in progress use the ps option:

When Compose is running independently to stop the services, use:

If you want to completely remove the containers, use the down option:

Passing the --volumes switch will also remove data volumes:

Uninstalling Docker Compose

If for any reason you want to uninstall Docker Compose you can simply delete the binary by typing:

Conclusion

You learned how to install and use Docker Compose on Ubuntu 18.04. If you have any questions, please leave a comment below.


Source link

6 comments

  1. After reading your blog post, I browsed your website a bit and noticed you aren’t ranking nearly as well in Google as you could be. I possess a handful of blogs myself, and I think you should take a look at “seowebsitetrafficnettools”, just google it. You’ll find it’s a very lovely SEO tool that can bring you a lot more visitors and improve your ranking. They have more than 30+ tools only 20$. Very cheap right? Keep up the quality posts

  2. After reading your blog post, I have a special offer for you, build your successful business with our company. it’s helpful for any type of website and business. vary cheap then another else offer. so, what are you waiting for? Keep up the quality posts

  3. After reading your blog post, I have a special offer for you, build your successful business with our company. it’s helpful for any type of website and business. vary cheap then another else offer. so, what are you waiting for? Keep up the quality posts

  4. After reading your blog post, I have a special offer for you, build your successful business with our company. it’s helpful for any type of website and business. vary cheap then another else offer. so, what are you waiting for? Keep up the quality posts

  5. After reading your blog post, I have a special offer for you, build your successful business with our company. it’s helpful for any type of website and business. vary cheap then another else offer. so, what are you waiting for? Keep up the quality posts

  6. After reading your blog post, I have a special offer for you, build your successful business with our company. it’s helpful for any type of website and business. vary cheap then another else offer. so, what are you waiting for? Keep up the quality posts

Leave a Reply

Your email address will not be published.