You are on page 1of 2

Exercise

Write the steps for creating your first container using Docker Platform.

Here are the steps for creating your first container using Docker Platform:

Steps:

1. Choose a Base Image: The first step is to select a base image. This image acts as a
starting point for your container and already includes an operating system and any
necessary software. Docker Hub is a public repository with a vast collection of
pre-built images you can leverage. You can browse images on
https://hub.docker.com/.

For this example, let's use a simple Ubuntu image:

Ubuntu:latest

2. Run the Container: The most basic way to create and run a container is using the
docker run command followed by the image name.
docker run ubuntu:latest
This will download the Ubuntu image (if not already downloaded) and start a
container based on it. The container will run and then exit.

3. Explore the Container : By default, the docker run command runs the container in
detached mode, meaning it runs in the background and exits when the process inside
finishes.

To interact with the container and explore its environment, you can use the -it flag
with the docker run command. This will start the container in interactive mode and
attach your terminal to it.
docker run -it ubuntu:latest

Once inside the container, you'll have a standard Ubuntu terminal. You can use basic
Linux commands to navigate the filesystem, see what software is installed, etc.

4. Exit the Container: When you're done exploring the container, you can exit it using
the exit command, similar to how you would exit a regular terminal session.

5. Understanding Container vs. Image: It's important to understand the difference


between a Docker image and a container. The image is a blueprint or template that
defines the container's configuration. A container is a running instance of an image.
You can create multiple containers from the same image.

You might also like