Home Explore Blog CI



docker

1st chunk of `content/manuals/engine/network/tutorials/standalone.md`
6d11dfbd51852a098fe50d421357067a731112b123ce19160000000100000fa8
---
title: Networking with standalone containers
description: Tutorials for networking with standalone containers
keywords: networking, bridge, routing, ports, overlay
aliases:
  - /network/network-tutorial-standalone/
---

This series of tutorials deals with networking for standalone Docker containers.
For networking with swarm services, see
[Networking with swarm services](/manuals/engine/network/tutorials/overlay.md). If you need to
learn more about Docker networking in general, see the [overview](/manuals/engine/network/_index.md).

This topic includes two different tutorials. You can run each of them on
Linux, Windows, or a Mac, but for the last one, you need a second Docker
host running elsewhere.

- [Use the default bridge network](#use-the-default-bridge-network) demonstrates
  how to use the default `bridge` network that Docker sets up for you
  automatically. This network is not the best choice for production systems.

- [Use user-defined bridge networks](#use-user-defined-bridge-networks) shows
  how to create and use your own custom bridge networks, to connect containers
  running on the same Docker host. This is recommended for standalone containers
  running in production.

Although [overlay networks](/manuals/engine/network/drivers/overlay.md) are generally used for swarm services,
you can also use an overlay network for standalone containers. That's covered as
part of the [tutorial on using overlay networks](/manuals/engine/network/tutorials/overlay.md#use-an-overlay-network-for-standalone-containers).

## Use the default bridge network

In this example, you start two different `alpine` containers on the same Docker
host and do some tests to understand how they communicate with each other. You
need to have Docker installed and running.

1.  Open a terminal window. List current networks before you do anything else.
    Here's what you should see if you've never added a network or initialized a
    swarm on this Docker daemon. You may see different networks, but you should
    at least see these (the network IDs will be different):

    ```console
    $ docker network ls

    NETWORK ID          NAME                DRIVER              SCOPE
    17e324f45964        bridge              bridge              local
    6ed54d316334        host                host                local
    7092879f2cc8        none                null                local
    ```

    The default `bridge` network is listed, along with `host` and `none`. The
    latter two are not fully-fledged networks, but are used to start a container
    connected directly to the Docker daemon host's networking stack, or to start
    a container with no network devices. This tutorial will connect two
    containers to the `bridge` network.

2.  Start two `alpine` containers running `ash`, which is Alpine's default shell
    rather than `bash`. The `-dit` flags mean to start the container detached
    (in the background), interactive (with the ability to type into it), and
    with a TTY (so you can see the input and output). Since you are starting it
    detached, you won't be connected to the container right away. Instead, the
    container's ID will be printed. Because you have not specified any
    `--network` flags, the containers connect to the default `bridge` network.

    ```console
    $ docker run -dit --name alpine1 alpine ash

    $ docker run -dit --name alpine2 alpine ash
    ```

    Check that both containers are actually started:

    ```console
    $ docker container ls

    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    602dbf1edc81        alpine              "ash"               4 seconds ago       Up 3 seconds                            alpine2
    da33b7aa74b0        alpine              "ash"               17 seconds ago      Up 16 seconds                           alpine1
    ```

3.  Inspect the `bridge` network to see what containers are connected to it.

Title: Networking with Standalone Docker Containers: Default Bridge Network
Summary
This document provides tutorials on networking standalone Docker containers, contrasting with swarm service networking. It covers using the default 'bridge' network (suitable for basic setups) and creating user-defined bridge networks (recommended for production). The tutorial demonstrates starting two Alpine containers on the same Docker host and examining their communication via the default bridge network.