podman ports connection refused after stopping and starting/restarting pod

Viewed 757

I'm new to using podman and am trying to follow along with Richard Walker's tutorial for containerizing a django app (https://www.richardwalker.dev/django-podman.html)

It works fine until I try to stop and restart the pod. Then my host machine can no longer connect to ports (which were exposed when building the images and mapped when the pod was created). The docs & guides suggest that it is a simple as issuing

podman pod stop ...
podman pod start ...

but this does not seem to work.
Would appreciate your help if you can see that I am missing something.


$ podman pod create -p 8000 -p 7000 -p 5432 -n cardpod
8553ad8fc0b14a849598a51c4ffcbffa9d6d094b96b542f0e432fc0d6dfd22ff

$ podman run --name deckofcards-prod-ctr --pod cardpod -d richardwalker.dev/deckofcards-prod-img
3dbf6f9ad043fe65492f0e15be642af92916ad9e09d941e1f96315343a8d2fae

$ curl http://127.0.0.1:7000/deck/
[{"suit":"clubs","face":"queen","value":10},{"suit":"spades","face":"four","value":4},{"suit":"hearts","face":"king","value":10},{"suit":"diamonds","face":"six","value":6},{"suit":"hearts","face":"two","value":2},{"suit":"diamonds","face":"ace","value":1},{"suit":"hearts","face":"eight","value":8},{"suit":"clubs","face":"three","value":3},{"suit":"spades","face":"five","value":5},{"suit":"clubs","face":"nine","value":9},{"suit":"spades","face":"nine","value":9},{"suit":"diamonds","face":"five","value":5},{"suit":"hearts","face":"nine","value":9},{"suit":"diamonds","face":"two","value":2},{"suit":"clubs","face":"king","value":10},{"suit":"diamonds","face":"eight","value":8},{"suit":"clubs","face":"ace","value":1},{"suit":"hearts","face":"three","value":3},{"suit":"spades","face":"jack","value":10},{"suit":"hearts","face":"ten","value":10},{"suit":"spades","face":"king","value":10},{"suit":"spades","face":"ace","value":1},{"suit":"spades","face":"ten","value":10},{"suit":"hearts","face":"five","value":5},{"suit":"hearts","face":"ace","value":1},{"suit":"clubs","face":"eight","value":8},{"suit":"hearts","face":"jack","value":10},{"suit":"diamonds","face":"queen","value":10},{"suit":"clubs","face":"ten","value":10},{"suit":"diamonds","face":"nine","value":9},{"suit":"clubs","face":"five","value":5},{"suit":"clubs","face":"jack","value":10},{"suit":"diamonds","face":"ten","value":10},{"suit":"hearts","face":"queen","value":10},{"suit":"diamonds","face":"seven","value":7},{"suit":"hearts","face":"seven","value":7},{"suit":"hearts","face":"six","value":6},{"suit":"spades","face":"two","value":2},{"suit":"clubs","face":"two","value":2},{"suit":"clubs","face":"seven","value":7},{"suit":"spades","face":"seven","value":7},{"suit":"clubs","face":"four","value":4},{"suit":"spades","face":"queen","value":10},{"suit":"diamonds","face":"king","value":10},{"suit":"spades","face":"six","value":6},{"suit":"diamonds","face":"jack","value":10},{"suit":"diamonds","face":"four","value":4},{"suit":"hearts","face":"four","value":4},{"suit":"clubs","face":"six","value":6},{"suit":"diamonds","face":"three","value":3},{"suit":"spades","face":"three","value":3},{"suit":"spades","face":"eight","value":8}] 


$ podman pod stop cardpod
8553ad8fc0b14a849598a51c4ffcbffa9d6d094b96b542f0e432fc0d6dfd22ff

$ podman pod start cardpod
8553ad8fc0b14a849598a51c4ffcbffa9d6d094b96b542f0e432fc0d6dfd22ff

$ curl http://127.0.0.1:7000/deck/
curl: (7) Failed to connect to 127.0.0.1 port 7000: Connection refused

More Info:

I can see that the django servers are running by inspecting "podman logs <container_id>" and the mapped ports are still available from viewing "podman port <pod_id>"

dockerfile as per tutorial:


# FROM directive instructing base image to build upon
FROM python:3.7-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Create and change to working dir
RUN mkdir /code
WORKDIR /code

# Copy code
COPY /release/ /code/

# Install dependencies
COPY requirements.txt /code/
RUN pip install -r requirements.txt

# EXPOSE port 7000 to allow communication to/from server
EXPOSE 7000

# CMD specifies the command to execute to start the server running.
CMD python3 manage.py runserver 0.0.0.0:7000

podman: version 2.0.2
distro: ubuntu 18.04

0 Answers
Related