josiahcarlson / redis-in-action

Example code from the book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redis service is never up in python/docker-compose.yml

rilma opened this issue · comments

After making a fork of this repository and checkout out from master branch, I find the following error in Github Codespaces VM (Ubuntu 18.04.1; Docker Compose 1.29.2)

@rilma ➜ /workspaces/redis-in-action (task/python-qa) $ cd python/
@rilma ➜ /workspaces/redis-in-action/python (task/python-qa) $ docker-compose up -d
Building python
[+] Building 1.7s (10/10) FINISHED                                                                                                                                              
 => [internal] load build definition from Dockerfile                                                                                                                       0.2s
 => => transferring dockerfile: 34B                                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                                          0.3s
 => => transferring context: 2B                                                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/python:3.6                                                                                                              1.0s
 => [auth] library/python:pull token for registry-1.docker.io                                                                                                              0.0s
 => [1/4] FROM docker.io/library/python:3.6@sha256:f8652afaf88c25f0d22354d547d892591067aa4026a7fa9a6819df9f300af6fc                                                        0.0s
 => [internal] load build context                                                                                                                                          0.1s
 => => transferring context: 37B                                                                                                                                           0.0s
 => CACHED [2/4] WORKDIR /usr/src/app                                                                                                                                      0.0s
 => CACHED [3/4] COPY requirements.txt ./                                                                                                                                  0.0s
 => CACHED [4/4] RUN pip install --no-cache-dir -r requirements.txt                                                                                                        0.0s
 => exporting to image                                                                                                                                                     0.2s
 => => exporting layers                                                                                                                                                    0.0s
 => => writing image sha256:2130d016f3b65f51f29038dd31108061b43ec6a19c212e86967e74ab04e0eaaa                                                                               0.0s
 => => naming to docker.io/library/python:redis-in-action                                                                                                                  0.0s
WARNING: Image for service python was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Pulling redis (redis:latest)...
latest: Pulling from library/redis
f1f26f570256: Pull complete
8a1809b0503d: Pull complete
d792b14d05f9: Pull complete
ad29eaf93bf6: Pull complete
7cda84ccdb33: Pull complete
95f837a5984d: Pull complete
Digest: sha256:7b83a0167532d4320a87246a815a134e19e31504d85e8e55f0bb5bb9edf70448
Status: Downloaded newer image for redis:latest
Creating redis-in-action-python ... 
Creating redis-in-action-redis  ... 
Creating redis-in-action-python ... done
ERROR: for redis-in-action-redis  "host" network_mode is incompatible with port_bindings

ERROR: for redis  "host" network_mode is incompatible with port_bindings
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 203, in perform_command
  File "compose/metrics/decorator.py", line 18, in wrapper
  File "compose/cli/main.py", line 1186, in up
  File "compose/cli/main.py", line 1182, in up
  File "compose/project.py", line 702, in up
  File "compose/parallel.py", line 108, in parallel_execute
  File "compose/parallel.py", line 206, in producer
  File "compose/project.py", line 688, in do
  File "compose/service.py", line 564, in execute_convergence_plan
  File "compose/service.py", line 480, in _execute_convergence_create
  File "compose/parallel.py", line 108, in parallel_execute
  File "compose/parallel.py", line 206, in producer
  File "compose/service.py", line 478, in <lambda>
  File "compose/service.py", line 457, in create_and_start
  File "compose/service.py", line 334, in create_container
  File "compose/service.py", line 941, in _get_container_create_options
  File "compose/service.py", line 1073, in _get_container_host_config
  File "docker/api/container.py", line 598, in create_host_config
  File "docker/types/containers.py", line 339, in __init__
docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings
[8368] Failed to execute script docker-compose
@rilma ➜ /workspaces/redis-in-action/python (task/python-qa) $

The corresponding Python and Redis Docker images are downloaded, but only Python service is up. Redis service is down. The Docker Compose file may require a fix.

@rilma ➜ /workspaces/redis-in-action/python (task/python-qa) $ docker image ls
REPOSITORY   TAG               IMAGE ID       CREATED        SIZE
python       redis-in-action   2130d016f3b6   25 hours ago   911MB
redis        latest            31f08b90668e   10 days ago    117MB
@rilma ➜ /workspaces/redis-in-action/python (task/python-qa) $ docker container ls
CONTAINER ID   IMAGE                    COMMAND     CREATED              STATUS              PORTS     NAMES
d7067126edfc   python:redis-in-action   "python3"   About a minute ago   Up About a minute             redis-in-action-python
@rilma ➜ /workspaces/redis-in-action/python (task/python-qa) $

PR #97 is an attempt for a fix

PR #97 has been merged by @josiahcarlson
Closing this issue