You can use containers to create portable workloads which run on your local computer, on physical and virtual servers, on public cloud infrastructure, and on embedded devices. A computer’s instruction set impacts container creation. This Learning Path provides a short introduction to Docker followed by information about how to build, run and share Docker images for the Arm architecture.
You can use any computer running Docker to complete this topic.
To confirm that Docker is installed correctly run the following command:
docker run hello-world
If Docker is installed and working correctly you see the following message:
Hello from Docker!
This message shows that your installation appears to be working correctly.
Note: If you do not see the message above, go to Installing Docker and follow the instructions to complete the installation.
The sections describe how to:
To build a Docker image:
Dockerfile
:
FROM ubuntu:latest
CMD echo -n "Architecture is " && uname -m
docker build
command. For example:
docker build -t uname .
Note: The -t
argument is the tag, a human-readable name for the final image. The .
specifies the PATH
to find the files for the build.
To create a container from the image enter the command:
docker run --rm uname
This command displays the architecture.
The output depends on the operating system and architecture of your computer. The following table shows the most common values.
Operating System and Architecture | Console Output |
---|---|
Any OS on Intel or AMD | Architecture is x64_86 |
Linux on Arm 64-bit | Architecture is aarch64 |
Linux on Arm 32-bit | Architecture is armv7l |
macOS on Apple Silicon | Architecture is arm64 |
The docker images
command lists all the images available on your computer. Docker image names have the form: repository/image-name:tag
Run the docker images
command to see the list of images:
docker images
The output is similar to this example:
REPOSITORY TAG IMAGE ID CREATED SIZE
uname latest f0a8125a81d3 5 days ago 69.2MB
This example shows the image name is uname
and the tag is latest
. If you do not specify a tag name, latest
is the default value.
You can save and share Docker images in repositories. The most common repository is Docker Hub . Repositories are also available from software providers and cloud service providers.
Before saving the image to Docker Hub:
Create an account on Docker Hub and note your username and password.
Use the docker tag
command to modify the image name to include your Docker hub username:
docker tag uname username/uname
docker login
docker push
command to save the image to your Docker Hub account:
docker push username/uname
In a browser, log in to Docker Hub. The new image is visible in your account.
(optional) Create a container from the Docker image on another computer with the same architecture.
If you have another computer with the same architecture you can run the image from Docker Hub.
Make sure Docker is installed on the second computer.
On the second computer, enter the docker run
command to create a container from the shared image. For example:
docker run --rm username/uname
Because the image is not on the local computer, Docker downloads it from Docker Hub and creates a container.
You do not need to rebuild the Docker image on the second computer.
In this section you learned how to build, run, and share a Docker image.
You used computers with the same instruction set architecture to build and share the Docker image.
To support multiple computer architectures, you can use a single Docker image that supports multi-architectures.
Continue the Learning Path to learn about multi-architecture images.