How-To Guides
Applications Guides

Add an Application Container Using Docker Compose

6min

You can add an application container to the Applications > Containers pane using Docker Compose.

See the Docker Hub Nginx Image page for more information.

You can also leverage Docker Compose in Manufacturing Connect. See Set Up Docker Container Configurations for an Application Release for details.

For this use case, we will add a Docker compose container, add and run an Nginix container, verify that the resulting website is running, and then remove the container.

Step 1: Add a Docker Compose Container

To add a Docker Compose container:

  1. In Manufacturing Connect Edge, navigate to Applications > Containers. The Containers pane appears.
  2. Click Run. The Enter command to run field appears.
  3. Enter the following: docker run -it -d --name compose -v /var/run/docker.sock: /var/run/docker.sock docker/compose:latest /bin/sh
  4. Click Run. The named container appears in the Containers pane and displays a running state. The container runs locally.

Step 2: Add the Nginx Container

To add the Nginx container:

  1. From the Containers pane, click the Terminal icon next to the compose container created in step 1. The compose shell opens.
  2. Enter docker ps -a and press ENTER. A list of the running containers appears.
  3. Enter cd ~ and press ENTER.
  4. Enter mkdir new and press ENTER.
  5. Enter cd new and press ENTER. The directory changes to /new.
  6. Enter vi docker-compose.yaml and press ENTER. The compose.yaml file opens.
  7. Paste the following code into the compose.yaml file as plain text. version: '3' services: web: image: nginx volumes: - ./templates:/etc/nginx/templates ports: - "3000:80" environment: - NGINX_HOST=foobar.com - NGINX_PORT=80
  8. Press Esc and enter :wq to save and exit the compose.yaml file. You are returned to the compose shell.
  9. From the /new directory, enter docker-compose up and press ENTER. A series of commands appears, creating and attaching to new_web_1.
  10. Click the Containers link at the top of the terminal to return to the Containers pane, and then refresh the page. The new_web_1 for the nginix container appears and is running.

Step 3: Verify that Nginx in Running

To verify that Nginx is running:

  1. Open a new browser tab.
  2. Copy the IP address from the Manufacturing Connect Edge browser tab.
  3. Paste the IP address in the new browser tab and add :3000 to the end. For example: https://192.168.7.16:3000

The Welcome to nginx! page appears.

Welcome to nginx! page
Welcome to nginx! page


Step 4: Remove the Nginx Container

You will now need to remove the Nginx container.

To remove the Nginx container:

  1. From the compose terminal shell, press Ctrl+C to stop the compose container.
  2. Enter docker-compose down and press ENTER. The new_web_1 for the nginx container is removed.

Step 5: Verify the Nginx Container is Removed

Click the Containers link at the top of the terminal to return to the Containers pane, and then refresh the page.

The new_web_1 for the nginix container no longer appears.

Example terminal code:

Example code
Example code