hgop / syllabus-2022

0 stars 1 forks source link

Day 06: docker-compose not working #31

Closed Hjortur17 closed 2 years ago

Hjortur17 commented 2 years ago

Expected Behaviour

I am trying to finish up day 06 by creating docker-compose.yaml file

Current Behaviour

I get some weird error (see picture below)

Context

Failure Logs

Screenshot 2022-11-29 at 12 44 32

Fanneyyy commented 2 years ago

Where is the docker-compose file located? If you want to have a docker-compose file that runs the server, db and client you'll need to have it top level, then change the build context, e.g. in the server the build context is "." because it's the current directory, when the docker-compose is top level in your repo you need to change the build context to the path to either the client or the server, depending on the service.

finnure commented 2 years ago

@Fanneyyy Why is there no network in the server docker-compose.yaml? Isn't it recommended when you have a docker compose with multiple services that communicate internally to have a network setup for local communication, instead of exposing it on the host?

Fanneyyy commented 2 years ago

We're only using the docker compose to run services locally, not in a remote cluster so just what you feel is nice to be able to run services locally and have them communicate, dealer's choice 😊

Hjortur17 commented 2 years ago

I have the docker-compose file located at the root of the project.

Here is the client (the httpbin is the same) for example:

client:
    build: ./src/connect4-client
    ports:
      - "3000:3000"

And then I have the server basically the same as from the file which was provided but I don't have the links and depends_on section.

Hjortur17 commented 2 years ago

Looks like it something related to httpbin, because it doesn't have a Dockerfile. Are we suppose to create one or is there some image that we can use?

Fanneyyy commented 2 years ago

httpbin does not need a dockerfile, the image is always fetched from dockerhub, you can skip it, no need to add it to the docker-compose file :)

Hjortur17 commented 2 years ago

Okay, but I don't fully understand why it isn't fetching these two dependancies

Screenshot 2022-11-29 at 19 19 35

Hjortur17 commented 2 years ago

Okay I was able to get this working by running this command: rm ~/.docker/config.json

But I would like to know if this is what we are suppose to get :)

Screenshot 2022-11-29 at 19 54 24

finnure commented 2 years ago

It looks like only the server and client are running.

docker ps -a

This command should show you a list of all containers on your computer. If it lists server, database, migration and client, and the migration one is stoped/exited, you should be good.