<p>By default Docker uses the <code>bridge</code> network.</p>
<p>On a default Docker installation you can simply map a port to the container's service port.  The Redis Docker image exposes its service on port <code>6379</code> so you can do:</p>
<p><code>$ docker run --name rd -d -p 6379:6379 redis:latest</code></p>
<p>From your host you can now run use the <code>redis-cli</code> utility:</p>
<pre><code>$ redis-cli
127.0.0.1:6379&gt; ping
PONG
127.0.0.1:6379&gt;
</code></pre>

CC BY-SA 4.0
2020-09-25T13:27:45.520Z
2020-09-25T13:27:45.520Z
swysocki
<p>tentative answer:</p>
<pre><code>root $ 
root $ docker run --name rds -d redis redis-server --appendonly yes
d85ce8736fc33f81edc7e63972391f6eb34586d562b4066f57395f9ea2bafe58
root $ 
root $ docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
d85ce8736fc3        redis               &quot;docker-entrypoint.s…&quot;   9 seconds ago       Up 6 seconds        6379/tcp            rds
root $ 
root $ docker exec -it rds redis-cli
127.0.0.1:6379&gt; 
127.0.0.1:6379&gt; keys *
(empty array)
127.0.0.1:6379&gt; 
127.0.0.1:6379&gt; set foo bar
OK
127.0.0.1:6379&gt; 
127.0.0.1:6379&gt; keys *
1) &quot;foo&quot;
127.0.0.1:6379&gt; 
127.0.0.1:6379&gt; get foo
&quot;bar&quot;
127.0.0.1:6379&gt; 
</code></pre>
<p>should work as persistence in a microservice architecture.  To my understanding.</p>
<pre><code>root $ 
root $ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
e57e2c862b19        bridge              bridge              local
25aba55a5413        host                host                local
ad5c1c2fa1e1        none                null                local
root $ 
root $ docker inspect rds | grep bridge
                &quot;bridge&quot;: {
root $ 
root $ docker network inspect bridge
[
    {
        &quot;Name&quot;: &quot;bridge&quot;,
        &quot;Id&quot;: &quot;e57e2c862b19e68b470adf5bbd4719b675c15a399e3bd01380a9d7ad35c7ea26&quot;,
        &quot;Created&quot;: &quot;2020-09-24T17:43:14.098411476-07:00&quot;,
        &quot;Scope&quot;: &quot;local&quot;,
        &quot;Driver&quot;: &quot;bridge&quot;,
        &quot;EnableIPv6&quot;: false,
        &quot;IPAM&quot;: {
            &quot;Driver&quot;: &quot;default&quot;,
            &quot;Options&quot;: null,
            &quot;Config&quot;: [
                {
                    &quot;Subnet&quot;: &quot;172.17.0.0/16&quot;,
                    &quot;Gateway&quot;: &quot;172.17.0.1&quot;
                }
            ]
        },
        &quot;Internal&quot;: false,
        &quot;Attachable&quot;: false,
        &quot;Ingress&quot;: false,
        &quot;ConfigFrom&quot;: {
            &quot;Network&quot;: &quot;&quot;
        },
        &quot;ConfigOnly&quot;: false,
        &quot;Containers&quot;: {
            &quot;d85ce8736fc33f81edc7e63972391f6eb34586d562b4066f57395f9ea2bafe58&quot;: {
                &quot;Name&quot;: &quot;rds&quot;,
                &quot;EndpointID&quot;: &quot;b0afddd9a063d8051021db490342e6627bdf9694b8f526ad5bbd5a665eeafefd&quot;,
                &quot;MacAddress&quot;: &quot;02:42:ac:11:00:02&quot;,
                &quot;IPv4Address&quot;: &quot;172.17.0.2/16&quot;,
                &quot;IPv6Address&quot;: &quot;&quot;
            }
        },
        &quot;Options&quot;: {
            &quot;com.docker.network.bridge.default_bridge&quot;: &quot;true&quot;,
            &quot;com.docker.network.bridge.enable_icc&quot;: &quot;true&quot;,
            &quot;com.docker.network.bridge.enable_ip_masquerade&quot;: &quot;true&quot;,
            &quot;com.docker.network.bridge.host_binding_ipv4&quot;: &quot;0.0.0.0&quot;,
            &quot;com.docker.network.bridge.name&quot;: &quot;docker0&quot;,
            &quot;com.docker.network.driver.mtu&quot;: &quot;1500&quot;
        },
        &quot;Labels&quot;: {}
    }
]
root $ 
</code></pre>
<p>So a <code>flask</code> container also on the bridge network should be able to access this container.</p>

CC BY-SA 4.0
2020-09-25T21:19:06.077Z
2020-09-25T21:19:06.077Z
Nicholas Saunders
<p>I'd like to be able to connect directly to the <code>redis</code> container below:</p>
<pre><code>root $ 
root $ docker images redis
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               alpine              bd71e6db4a54        2 weeks ago         32.2MB
redis               latest              84c5f6e03bf0        2 weeks ago         104MB
root $ 
root $ docker run --name rd -d -p 99:99 redis:latest
ac4b8b2b032b2c2911f03fd4f6af649f470620cd29eb566b821e5ce738d9ac11
root $ 
root $ docker exec -ti --user root rd bash
root@ac4b8b2b032b:/data# 
root@ac4b8b2b032b:/data# redis-cli
127.0.0.1:6379&gt; 
127.0.0.1:6379&gt; exit
root@ac4b8b2b032b:/data# 
root@ac4b8b2b032b:/data# exit
exit
root $ 
root $ docker network ls
NETWORK ID          NAME                    DRIVER              SCOPE
74c94db9195c        basexhttpnetwork        bridge              local
a5efbdf4bc39        bridge                  bridge              local
4b6586d1bc8c        frappe_docker_default   bridge              local
1b875368faa0        helloworld_default      bridge              local
3bc6659535b4        host                    host                local
e877e399bf78        none                    null                local
root $ 
root $ docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                          NAMES
ac4b8b2b032b        redis:latest        &quot;docker-entrypoint.s…&quot;   6 minutes ago       Up 6 minutes        0.0.0.0:99-&gt;99/tcp, 6379/tcp   rd
root $ 
</code></pre>
<p>using the <code>redis-cli</code> tool from the host.  So I would need to add or attach the <code>rd</code> (for <code>redis</code>) container to the bridge driver?  Then specify an IP address and port from the host?</p>

<docker><networking><databases><ports><redis>
How do I make a redis container accessible through bridge networking from the host?
Nicholas Saunders
# How do I make a redis container accessible through bridge networking from the host?

(Asked by: username_0 on 2020-09-24)

I'd like to be able to connect directly to the redis container below:
root $ 
root $ docker images redis
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               alpine              bd71e6db4a54        2 weeks ago         32.2MB
redis               latest              84c5f6e03bf0        2 weeks ago         104MB
root $ 
root $ docker run --name rd -d -p 99:99 redis:latest
ac4b8b2b032b2c2911f03fd4f6af649f470620cd29eb566b821e5ce738d9ac11
root $ 
root $ docker exec -ti --user root rd bash
root@ac4b8b2b032b:/data# 
root@ac4b8b2b032b:/data# redis-cli
127.0.0.1:6379> 
127.0.0.1:6379> exit
root@ac4b8b2b032b:/data# 
root@ac4b8b2b032b:/data# exit
exit
root $ 
root $ docker network ls
NETWORK ID          NAME                    DRIVER              SCOPE
74c94db9195c        basexhttpnetwork        bridge              local
a5efbdf4bc39        bridge                  bridge              local
4b6586d1bc8c        frappe_docker_default   bridge              local
1b875368faa0        helloworld_default      bridge              local
3bc6659535b4        host                    host                local
e877e399bf78        none                    null                local
root $ 
root $ docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                          NAMES
ac4b8b2b032b        redis:latest        "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        0.0.0.0:99->99/tcp, 6379/tcp   rd
root $ 

using the redis-cli tool from the host.  So I would need to add or attach the rd (for redis) container to the bridge driver?  Then specify an IP address and port from the host?

**Tags:** docker, networking, databases, ports, redis


---

## 2 answers

### Answer by username_1 on 2020-09-25. Score: 1

By default Docker uses the bridge network.
On a default Docker installation you can simply map a port to the container's service port.  The Redis Docker image exposes its service on port 6379 so you can do:
$ docker run --name rd -d -p 6379:6379 redis:latest
From your host you can now run use the redis-cli utility:
$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>


---

### Answer by username_0 on 2020-09-25. Score: 0

tentative answer:
root $ 
root $ docker run --name rds -d redis redis-server --appendonly yes
d85ce8736fc33f81edc7e63972391f6eb34586d562b4066f57395f9ea2bafe58
root $ 
root $ docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
d85ce8736fc3        redis               "docker-entrypoint.s…"   9 seconds ago       Up 6 seconds        6379/tcp            rds
root $ 
root $ docker exec -it rds redis-cli
127.0.0.1:6379> 
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> 
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> 
127.0.0.1:6379> keys *
1) "foo"
127.0.0.1:6379> 
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> 

should work as persistence in a microservice architecture.  To my understanding.
root $ 
root $ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
e57e2c862b19        bridge              bridge              local
25aba55a5413        host                host                local
ad5c1c2fa1e1        none                null                local
root $ 
root $ docker inspect rds | grep bridge
                "bridge": {
root $ 
root $ docker network inspect bridge
[
    {
        "Name": "bridge",
        "Id": "e57e2c862b19e68b470adf5bbd4719b675c15a399e3bd01380a9d7ad35c7ea26",
        "Created": "2020-09-24T17:43:14.098411476-07:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "d85ce8736fc33f81edc7e63972391f6eb34586d562b4066f57395f9ea2bafe58": {
                "Name": "rds",
                "EndpointID": "b0afddd9a063d8051021db490342e6627bdf9694b8f526ad5bbd5a665eeafefd",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]
root $ 

So a flask container also on the bridge network should be able to access this container.


---

