Home Explore Blog CI



docker

4th chunk of `content/get-started/docker-concepts/the-basics/what-is-a-container.md`
3751c5760ca612c47529b643f2b35a1f8845c8edb71410990000000100000c01
1. Open your CLI terminal and start a container by using the [`docker run`](/reference/cli/docker/container/run/) command:

    ```console
    $ docker run -d -p 8080:80 docker/welcome-to-docker
    ```

    The output from this command is the full container ID. 

Congratulations! You just fired up your first container! 🎉

### View your running containers

You can verify if the container is up and running by using the [`docker ps`](/reference/cli/docker/container/ls/) command:

```console
docker ps
```

You will see output like the following:

```console
 CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS          PORTS                      NAMES
 a1f7a4bb3a27   docker/welcome-to-docker   "/docker-entrypoint.…"   11 seconds ago   Up 11 seconds   0.0.0.0:8080->80/tcp       gracious_keldysh
```

This container runs a web server that displays a simple website. When working with more complex projects, you'll run different parts in different containers. For example, a different container for the `frontend`, `backend`, and `database`.

> [!TIP]
>
> The `docker ps` command will show you _only_ running containers. To view stopped containers, add the `-a` flag to list all containers: `docker ps -a`


### Access the frontend

When you launched the container, you exposed one of the container's ports onto your machine. Think of this as creating configuration to let you to connect through the isolated environment of the container. 

For this container, the frontend is accessible on port `8080`. To open the website, select the link in the **Port(s)** column of your container or visit [http://localhost:8080](http://localhost:8080) in your browser.

![Screenshot of the landing page of the Nginx web server, coming from the running container](/Users/baehyunsol/Documents/Rust/ragit/sample/docker/content/get-started/docker-concepts/the-basics/images/access-the-frontend.webp?border)

### Stop your container

The `docker/welcome-to-docker` container continues to run until you stop it. You can stop a container using the `docker stop` command.

1. Run `docker ps` to get the ID of the container

2. Provide the container ID or name to the [`docker stop`](/reference/cli/docker/container/stop/) command:

    ```console
    docker stop <the-container-id>
    ```

> [!TIP]
>
> When referencing containers by ID, you don't need to provide the full ID. You only need to provide enough of the ID to make it unique. As an example, the previous container could be stopped by running the following command:
>
> ```console
> docker stop a1f
> ```

{{< /tab >}}
{{< /tabs >}}

## Additional resources

The following links provide additional guidance into containers:

- [Running a container](/engine/containers/run/)
- [Overview of container](https://www.docker.com/resources/what-container/)
- [Why Docker?](https://www.docker.com/why-docker/)

## Next steps

Now that you have learned the basics of a Docker container, it's time to learn about Docker images.

{{< button text="What is an image?" url="what-is-an-image" >}}

Title: Container Interaction and Management via CLI: Accessing, Stopping, and Additional Resources
Summary
This section details how to interact with and manage a Docker container using the command-line interface (CLI). It covers starting a container with `docker run`, viewing running containers with `docker ps`, accessing the container's frontend through a port, and stopping the container using `docker stop`. Additionally, it provides a tip about using `docker ps -a` to view all containers (including stopped ones) and offers links to further resources on containers and Docker in general.