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

How to use control docker containers via docker compose, inside the olivetin container #312

Open
nickelswitte opened this issue May 13, 2024 · 4 comments
Labels
type: question Further information is requested

Comments

@nickelswitte
Copy link

What seems to be the problem?!

I run all my services on my host machine using docker compose. In one case, a minecraft server. I would like to give others safe access to start and stop this server. I use olivetin inside a docker container itself. Somehow I cannot currently figure out, how to control docker containers on my host machine, from within the olivetin container. Here are my steps:

  1. I have the following docker compose file for olivetin:
services:
  olivetin:
    container_name: olivetin
    image: jamesread/olivetin
    volumes:
      - ./config:/config # replace host path or volume as needed
      - /var/run/docker.sock:/var/run/docker.sock
    #ports:
    #  - "1337:1337"
    restart: unless-stopped
    user: root
    privileged: true
  1. I managed to install docker compose inside the olivetin container (with the help from 89, although only until I restart the olivetin container, then it is lost again).
  2. I defined the following action:
  - title: Start Minecraft Server
    icon: restart
    shell: docker compose -f /home/myuser/apps/minecraft/docker-compose.yml up -d
  1. Other actions work well (e.g. ping, disc usage, etc.) but this one throws and error:
olivetin  | level="info" msg="Action finished" actionTitle="Start Minecraft Server" exit="14" stderr="stat /home/myuser/apps/minecraft/docker-compose.yml: no such file or directory\n" stdout="" timedOut="false"

It has not access to the docker compose file, as this one is on the host machine, and not in the olivetin container. But I am a bit confused. I run services like portainer, and am used to them controlling my other docker containers via the /var/run/docker.sock bind mount. However, when I follow the docs of olivetin, it rather seems like I am supposed to run docker within the olivetin container, and not on my host machine. Or I am not understanding something here.

So I guess the question is: How can I control containers on my host machine with docker compose correctly?

Can you provide a sosreport?

Build:
commit: c4d1a2a
version: 2024.03.24
date: \"2024-03-24T23:06:37Z\"

# Runtime:
os: linux
osreleaseprettyname: PRETTY_NAME=\"Fedora Linux 38 (Container Image)\"
arch: amd64
incontainer: true
lastbrowseruseragent: \"\"

# Config:
countofactions: 21
countofdashboards: 2
loglevel: INFO
listenaddresssinglehttpfrontend: 0.0.0.0:1337
listenaddresswebui: localhost:1340
listenaddressrestactions: localhost:1338
listenaddressgrpcactions: localhost:1339
timezone: Local

What package/file/container did you use to install OliveTin?

official latest tag, so I guess OliveTin-1234-x86_64.rpm

Your config.yaml

everything is default
@jamesread
Copy link
Collaborator

Heya @nickelswitte , very keen to help you out here, sorry that you found the documentation confusing.

Docker is preinsalled in the container, but not for running containers inside containers, but so that you can send start/stop commands to thr docker sock.

docker-compose is provided as a separate package inside Fedora (which OliveTin uses as the base container image), but this is docker-compose version 1.

So I hope this clears up your understanding:-) if anything is unclear please just say.

As an alternative, consider using ssh: https://docs.olivetin.app/action-ssh.html this requires a bit of setup, but it's generally less cumbersome to maintain.

@nickelswitte
Copy link
Author

Hello James,

Thank you a lot for the quick reply. Actually, I will don't understand it honestly.

I have two questions:

  • How do I use docker via the docker sock? Does this require a different command?
  • Which is the best way to permanently install docker-compose into the container? I tried it via an action and executeOnStartup, but I got timeouts and it was unsuccessful.

Sorry for the inconvenience!

@jamesread
Copy link
Collaborator

@nickelswitte , actually the docker that is inside the OliveTin container should automatically pick up the docker sock, you don't need to configure anything special for this.

When you say that execOnStartup failed for you, did you set the default timeout any higher? It defaults to 3 seconds I think, and you'll probably need somewhat more time than that :-)

Just set timeout: 60 on the action.

There is a discord link on the OliveTin homepage (https://www.olivetin.app/) if chat is easier for you :-)

@jamesread jamesread added the type: question Further information is requested label May 13, 2024
@nickelswitte
Copy link
Author

Thank you very much for the support. The timeout actually did the trick, with installing docker-compose.

But I have another question. Do you think it is even possible to use docker compose through the docker sock, in a similar manner like the normal docker start or docker stop commands? In my mind, a simple

docker-compose -f /home/myuser/apps/minecraft/docker-compose.yml up -d

should do the trick, but according to my tests it does not. I need access to the docker-compose.yml file inside olivetin. When I give access to it, via a bind mount, it creates a new container, rather than communicating with the existing ones. And when I think about it, even a popular container management software like portainer is only able to start and stop single containers, and not access the docker compose files, that I setup outside of it. What are your thoughts on this?

Or in other words: If I have a project that needs multiple containers (database, webserver, etc.) how would you control this with olivetin?

Thanks a lot for the help!

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

No branches or pull requests

2 participants