Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose straight into restarting #37

Closed
matthewfurr opened this issue Nov 8, 2019 · 11 comments
Closed

docker-compose straight into restarting #37

matthewfurr opened this issue Nov 8, 2019 · 11 comments
Labels
question Further information is requested

Comments

@matthewfurr
Copy link

matthewfurr commented Nov 8, 2019

I'm using docker-compose to start and stop my containers. As soon as listmonk is starting it has a status of "Restarting (1) Less than a second ago". Logs output something along the lines of

... main.go:112 reading config config.toml ...main.go:236 error connecting to DB dial tcp lookup demo-db on 127.0.0.11:53 no such host

I am unable to shell into the container and make adjustments to the config.toml because it is restarting. How should I proceed?

@knadh
Copy link
Owner

knadh commented Nov 8, 2019

listmonk needs to connect to a Postgres database to boot. Have you set that up?

These may be of help:
#25 (comment)
#21 (comment)

@matthewfurr
Copy link
Author

matthewfurr commented Nov 8, 2019

Thanks for the quick response. I have a PostgreSQL database already setup with other services. Based on comment #25, would this be the correct configuration of the volumes for the config.toml file?

version: "3"

networks:
  proxy:
    external: true
  internal:
    external: true

services:
  listmonk:
    image: listmonk/listmonk:latest
    container_name: listmonk
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    volumes:
      - /home/containers/listmonk/config.toml:./listmonk/config.toml
    networks:
      - proxy
      - internal
    labels:
      - "traefik.enable=true"
      - ...
      - "traefik.docker.network=proxy"
    depends_on:
      - postgres

Thanks again.

@mr-karan
Copy link
Collaborator

mr-karan commented Nov 8, 2019

@matthewfurr You're using demo-db in config.toml to connect, but since your Postgres service is external, so probably the hostname is different. Use the hostname/port of the existing Postgres and it should work.

Anyway, the docker-compose config is also wrong since you've a depends_on field with Postgres but you don't have the Postgres service definition inside docker-compose.

@matthewfurr
Copy link
Author

matthewfurr commented Nov 8, 2019

@mr-karan, that is correct and that is why I am asking how I can edit the config.toml if the container is always restarting? It goes straight into restarting once it has been started. Therefore, I cannot sh into the container to edit to config.toml and use my Postgres hostname/user/etc... This is why I started this issue.

The docker-compose file is fine. I wouldn't even be able to start the container if it was missing the Postgres service. I didn't think it was necessary to post the entire file with every service I have running. I removed the irrelevant services before posting what you see above.

Can you confirm that I have the correct configuration for volumes if I want to make config.toml accessible on my host machine?

@mr-karan
Copy link
Collaborator

mr-karan commented Nov 8, 2019

why I am asking how I can edit the config.toml if the container is always restarting

Since you're mounting the config.toml as a bind mount, just edit this file locally with correct hostname for postgres and restart the containers.

cannot sh into the container to edit to config.toml

Yep and that's how it should be. config comes as a volume, not something you should change inside when container is running, since you would lose this config the next time container restarts.

didn't think it was necessary to post the entire file with every service I have running. I removed the irrelevant services before posting what you see above.

Got it. Since you hadn't mentioned that it's only a portion, I assumed incorrectly.

Can you confirm that I have the correct configuration for volumes

Yes looks fine, you just need to edit this file from your host machine with correct config.

@matthewfurr
Copy link
Author

matthewfurr commented Nov 8, 2019

@mr-karan, I haven't been able to successfully create the mount. I got a lot of errors mounting the volumes with my compose file above. So I made the changes you see below:

    volumes:
      - type: bind
        source: ./listmonk/config.toml
        target: /home/containers/listmonk/settings/config.toml

It is still trying to access the same demo database. Thoughts?

@mr-karan
Copy link
Collaborator

mr-karan commented Nov 9, 2019

Your source and target is opposite. Source is path on the host and target is the path inside container.

@knadh knadh added the question Further information is requested label Nov 9, 2019
@matthewfurr
Copy link
Author

matthewfurr commented Nov 14, 2019

@mr-karan & @knadh,

I'm using the following for my docker-compse.yml file, however, it is still trying to use the demo-db database. Please note that I haven't posted the entire file. Thoughts?

  listmonk:
    image: listmonk/listmonk:latest
    container_name: listmonk
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    volumes:
      - type: bind
        source: ./listmonk/config.toml
        target: /home/.../containers/listmonk/listmonk/config.toml
    networks:
      - proxy
      - internal
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.listmonk.entrypoints=http"
      - "traefik.http.routers.listmonk.rule=Host(`listmonk.domain.tld`)"
      - "traefik.http.routers.listmonk.middlewares=https-redirect@file"
      - "traefik.http.routers.listmonk-secure.entrypoints=https"
      - "traefik.http.routers.listmonk-secure.rule=Host(`listmonk.domain.tld`)"
      - "traefik.http.routers.listmonk-secure.tls=true"
      - "traefik.http.routers.listmonk-secure.tls.certresolver=digitalocean"
      - "traefik.http.routers.listmonk-secure.service=listmonk"
      - "traefik.http.services.listmonk.loadbalancer.server.port=9000"
      - "traefik.docker.network=proxy"
    depends_on:
      - postgres

@mr-karan
Copy link
Collaborator

mr-karan commented Nov 14, 2019

Your source and target is opposite. Source is path on the host and target is the path inside container.

So basically edit your docker-compose.yml and flip the source and target like:

source: /home/.../containers/listmonk/listmonk/config.toml
target:  ./listmonk/config.toml

And edit the file on host /home/.../containers/listmonk/listmonk/config.toml with your correct Postgres host.

Hope that helps. I am closing this issue since it's not a bug in listmonk but with your config.

@matthewfurr
Copy link
Author

@mr-karan, I made the changes you suggested above. However, docker gives me the following error:

Recreating listmonk ... error

ERROR: for listmonk  Cannot create container for service listmonk: invalid mount config for type "bind": invalid mount path: './listmonk/config.toml' mount path must be absolute

ERROR: for listmonk  Cannot create container for service listmonk: invalid mount config for type "bind": invalid mount path: './listmonk/config.toml' mount path must be absolute
ERROR: Encountered errors while bringing up the project.

@mr-karan
Copy link
Collaborator

docker run -v $(PWD)/config.toml:/listmonk/config.toml listmonk/listmonk:latest tried this and worked.

docker-compose equivalent:

source: /home/.../containers/listmonk/listmonk/config.toml
target:  /listmonk/config.toml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants