Add an Application Container Using Docker Compose
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.
To add a Docker Compose container:
- In Manufacturing Connect Edge, navigate to Applications > Containers. The Containers pane appears.
- Click Run. The Enter command to run field appears.
- Enter the following: docker run -it -d --name compose -v /var/run/docker.sock: /var/run/docker.sock docker/compose:latest /bin/sh
- Click Run. The named container appears in the Containers pane and displays a running state. The container runs locally.
To add the Nginx container:
- From the Containers pane, click the Terminal icon next to the compose container created in step 1. The compose shell opens.
- Enter docker ps -a and press ENTER. A list of the running containers appears.
- Enter cd ~ and press ENTER.
- Enter mkdir new and press ENTER.
- Enter cd new and press ENTER. The directory changes to /new.
- Enter vi docker-compose.yaml and press ENTER. The compose.yaml file opens.
- 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
- Press Esc and enter :wq to save and exit the compose.yaml file. You are returned to the compose shell.
- From the /new directory, enter docker-compose up and press ENTER. A series of commands appears, creating and attaching to new_web_1.
- 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.
To verify that Nginx is running:
- Open a new browser tab.
- Copy the IP address from the Manufacturing Connect Edge browser tab.
- 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.
You will now need to remove the Nginx container.
To remove the Nginx container:
- From the compose terminal shell, press Ctrl+C to stop the compose container.
- Enter docker-compose down and press ENTER. The new_web_1 for 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: