|
| 1 | +--- |
| 2 | +title: 'Managing Containers with Docker on Portenta X8' |
| 3 | +description: 'This tutorial shows how to install and manage your containers using Docker.' |
| 4 | +difficulty: easy |
| 5 | +tags: |
| 6 | + - containers |
| 7 | + - Docker |
| 8 | + - Hello-World |
| 9 | +author: 'Pablo Marquínez' |
| 10 | +software: |
| 11 | + - Terminal |
| 12 | + - Docker |
| 13 | +hardware: |
| 14 | + - hardware/04.pro/boards/portenta-x8 |
| 15 | +--- |
| 16 | + |
| 17 | +## Overview |
| 18 | + |
| 19 | +[Docker](http://docker.com) 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. |
| 20 | + |
| 21 | +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](hub.docker.com) page. |
| 22 | + |
| 23 | +In this tutorial we will go through the steps of how to install, run and remove the [Hello-World Container](https://hub.docker.com/_/hello-world) |
| 24 | + |
| 25 | +## Goals |
| 26 | + |
| 27 | +- List the installed and running containers |
| 28 | +- Install a container |
| 29 | +- Run a container manually |
| 30 | +- Uninstall a container |
| 31 | + |
| 32 | +### Required Hardware and Software |
| 33 | + |
| 34 | +- [Arduino Portenta X8](https://store.arduino.cc/products/portenta-x8) |
| 35 | +- USB-C cable (either USB-C to USB-A or USB-C to USB-C) |
| 36 | +- Wi-Fi Access Point with Internet Access |
| 37 | +- ADB or SSH. [Check how to connect to your Portenta X8](docs.arduino.cc/tutorials/portenta-x8/out-of-the-box#controlling-portenta-x8-through-the-terminal) |
| 38 | + |
| 39 | +## Using Docker |
| 40 | + |
| 41 | +The Docker CLI comes with your Portenta X8 by default, you can check if the tool is installed by typing: |
| 42 | +``` |
| 43 | +docker -v |
| 44 | +``` |
| 45 | + |
| 46 | +***To use this tool, first of all you will need to connect to your device, check [how to connect using adb/ssh](/tutorials/portenta-x8/out-of-the-box#controlling-portenta-x8-through-the-terminal).*** |
| 47 | + |
| 48 | +You can check the Docker reference documentation, which covers all the features of the tool in depth at [https://docs.docker.com/](docs.docker.com). |
| 49 | + |
| 50 | +The following steps shows how to install, run and uninstall the "Hello World" container. |
| 51 | + |
| 52 | +### Install A Container |
| 53 | + |
| 54 | +You will need to find your Docker container, on its Docker hub page it will show you how to install the desired container. |
| 55 | + |
| 56 | +https://hub.docker.com/_/hello-world |
| 57 | + |
| 58 | +``` |
| 59 | +docker pull hello-world |
| 60 | +``` |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +### Run The Installed Container |
| 65 | + |
| 66 | +``` |
| 67 | +docker run hello-world |
| 68 | +``` |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +***To be able to see your container with `docker ps -a` you will need to run it at least once with `docker run`*** |
| 73 | + |
| 74 | +### Listing The Installed Packages |
| 75 | +List the installed containers with the following command: |
| 76 | +``` |
| 77 | +docker ps -a |
| 78 | +``` |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +Keep in mind that you will need to get the `CONTAINER ID` to uninstall the container afterwards. |
| 83 | + |
| 84 | +If you didn't run your container you can also check if it's correctly installed by using: |
| 85 | +``` |
| 86 | +docker images |
| 87 | +``` |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | +### Uninstall A Container |
| 92 | + |
| 93 | +First get the Container ID from the container list. |
| 94 | + |
| 95 | +Then use the remove (`rm`) command |
| 96 | +``` |
| 97 | +docker container rm <CONTAINER ID> |
| 98 | +``` |
| 99 | + |
| 100 | +In this case we run `docker ps -a` and copy the `CONTAINER_ID` which in this case is `c44ba77b65cb`. |
| 101 | + |
| 102 | +***`CONTAINER_ID` changes its value every time you re-install them*** |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +If you run `docker images` again you will see that the container is not showing up anymore. |
| 107 | + |
| 108 | +## Conclusion |
| 109 | + |
| 110 | +In this tutorial you learned how to install a container onto your device, run it and manage it. |
| 111 | + |
| 112 | +### Next Steps |
| 113 | + |
| 114 | +- Now that you have the base of the workflow to use [Docker](https://docker.com), go to its docs page and make sure you understand all the features. |
| 115 | +- Look for a container from [Docker hub](http://hub.docker.com), install it and make your own application out of it. |
| 116 | +- Create a container to run your custom made application. |
0 commit comments