![]() – Now, to check if the container is running and up, use the below command: $ docker-compose ps Status: Downloaded newer image for nginx:latest ![]() When docker-compose is run, will create a separate container based on the latest official Nginx image and it will expose the port 80 on the container to port 8000 on the host machine.Ġ3- After saving the file, start the Nginx container as a background process with the following command: $ docker-compose up -dĬreating network "nginx_default" with the default driverĭigest: sha256:96fb261b66270b900ea5a2c17a26abbfabe95506e73c3a3c65869a6dbe83223a In the second section of services, we are are going to define a service called web. ![]() For full details, check Compose and Docker compatibility matrix. There are several different versions of the Compose file format with support for specific Docker releases. ![]() – The first line specifies the Compose file version. In this section, we’ll show how to use Docker Compose to run a Nginx container and expose it on your host machine.Ġ1- Create a new directory named nginx and move into it: $ mkdir ~/nginx & cd ~/nginxĠ2- Next, create docker-compose.yml file in your new directory and add the following lines: $ vi docker-compose.yml Step 2 – Getting started with Docker Compose In order to get the latest release of Docker Compose, go to the Docker’s GitHub repository site.Ġ1- Start by downloading the Docker Compose binary into the /usr/local/bin directory using the following curl command: $ sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-composeĠ2- Next, set the permissions to make the binary executable: $ sudo chmod +x /usr/local/bin/docker-composeĠ3- Then, verify that the installation was successful by checking the version: $ sudo docker-compose -versionĭocker-compose version 1.25.4, build 4667896bĠ4- Furthermore, to run Compose as a non-root user, add your user to the docker group as below. Follow our previous tutorial about How to Install Docker on CentOS 8 Step 1 - Install Docker Compose On CentOS 8 – Logged in as a user with sudo privileges. Make sure that you have met the following prerequisites before continuing with this tutorial:
0 Comments
Leave a Reply. |