0

docker/postgres/Dockerfile looks like this:

FROM postgres:14.5-alpine

WORKDIR /app

docker-compose.yml looks like this:

version: "3.9"

services:
  postgres:
#    image: postgres:14.5-alpine
    build: docker/postgres/Dockerfile
    ports:
      - "5432:5432"
    env_file: docker/postgres/.env

FWIW, docker/postgres/.env looks like this:

POSTGRES_USER=my_postgres
POSTGRES_PASSWORD=password
POSTGRES_DB=users

When I try to % docker compose up, I get the following error:

Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "postgres": executable file not found in $PATH: unknown
`docker-compose` process finished with exit code 1

Note that when I compose with the image instead of the build, everything works fine. What's the issue?

2
  • 1
    If you specify build you must indicate a folder, see doc. Remove Dockerfile from build. Write build: docker/postgres or dockerfile: docker/postgres/Dockerfile Commented Oct 14, 2022 at 8:20
  • @Max I get the same error Commented Oct 14, 2022 at 13:56

1 Answer 1

2
version: "3.9"

services:
  postgres:
    build:
      context: .
      dockerfile: docker/postgres/Dockerfile
    ports:
      - "5432:5432"
    env_file: docker/postgres/.env
Sign up to request clarification or add additional context in comments.

9 Comments

I get the same error
Sure, because you didn't kill or recreate container. After you changed the service name to "db", it created new container with "db" instead "postgres" in container name.
No, I did kill the container before rerunning docker compose
What command did you use?
I deleted the containers (and the images, and the volumes) on the docker desktop on the UI
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.