skip to Main Content

I’m following the tutorial in Use containers for development#Get and run the sample application | Docker Docs. At step 6, instead of getting an empty [] JSON string, I get:

curl http://localhost:8000/initdb
init database

curl http://localhost:8000/widget
<!doctype html>
<html lang=en>
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>

Why is that? Here is the result of docker ps -a

CONTAINER ID   IMAGE               COMMAND                  CREATED          STATUS          PORTS                    NAMES
2a87fc863140   python-docker-dev   "/bin/sh -c 'python …"   6 minutes ago    Up 6 minutes    0.0.0.0:8000->5000/tcp   rest-server
7d7eb37dc40e   postgres            "docker-entrypoint.s…"   12 minutes ago   Up 12 minutes   0.0.0.0:5432->5432/tcp   db

2

Answers


  1. You can try to debug the issue by using a web browser to access the two endpoints. If you can access the /initdb endpoint in a web browser, but not the /widget endpoint, then the problem is most likely with the application itself. If you cannot access either endpoint, then the problem is most likely with your local machine or network configuration.

    Login or Signup to reply.
  2. If you look at the code here, you can see that it sets up three endpoints: /, /initdb and /widgets. Those are the only routes that the app responds to.

    You’re trying to access /widget (without the ‘s’ at the end) and so you get a 404 Not Found.

    Try

    curl http://localhost:8000/widgets
    

    instead.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search