Managing Containers with Docker on Portenta X8

This tutorial shows how to install and manage your containers using Docker.

Overview

Docker Is a platform full of applications, called containers. Containers are isolated solutions and thus they don't have to depend on your environment. Making them portable and consistent throughout development, testing and production.

You can download, install, use and share applications in the form of containers. You can find all the available containers on the hub.docker.com page.

In this tutorial we will go through the steps of how to install, run and remove the Hello-World Container

Goals

  • List the installed and running containers
  • Install a container
  • Run a container manually
  • Uninstall a container

Required Hardware and Software

Using Docker

The Docker CLI comes with your Portenta X8 by default, you can check if the tool is installed by typing:

1docker -v

To use this tool, first of all you will need to connect to your device, check how to connect using adb/ssh.

You can check the Docker reference documentation, which covers all the features of the tool in depth at docs.docker.com.

The following steps shows how to install, run and uninstall the "Hello World" container.

Install A Container

You will need to find your Docker container, on its Docker hub page it will show you how to install the desired container.

https://hub.docker.com/_/hello-world

1docker pull hello-world

Docker CLI pulling a container
Docker CLI pulling a container

Run The Installed Container

1docker run hello-world

Docker CLI running Hello World app
Docker CLI running Hello World app

To be able to see your container with

docker ps -a
you will need to run it at least once with
docker run

Listing The Installed Packages

List the installed containers with the following command:

1docker ps -a

Docker CLI listing all the installed containers
Docker CLI listing all the installed containers

Keep in mind that you will need to get the

CONTAINER ID
to uninstall the container afterwards.

If you didn't run your container you can also check if it's correctly installed by using:

1docker images

Docker CLI images
Docker CLI images

Uninstall A Container

First get the Container ID from the container list.

Then use the remove (

rm
) command

1docker container rm <CONTAINER ID>

In this case we run

docker ps -a
and copy the
CONTAINER_ID
which in this case is
c44ba77b65cb
.

CONTAINER_ID
changes its value every time you re-install them

Docker CLI container uninstall
Docker CLI container uninstall

If you run

docker images
again you will see that the container is not showing up anymore.

Conclusion

In this tutorial you learned how to install a container onto your device, run it and manage it.

Next Steps

  • Now that you have the base of the workflow to use Docker, go to its docs page and make sure you understand all the features.
  • Look for a container from Docker hub, install it and make your own application out of it.
  • Create a container to run your custom made application.

Tutorial Toolbox

Contribute to Arduino

Join the community and suggest improvements to this article via GitHub. Make sure to read out contribution policy before making your pull request.

Missing something?

Check out our store and get what you need to follow this tutorial.

Suggest Changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.