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 do you use this to run docker commands? #735

Open
mmkk20158 opened this issue Feb 14, 2024 · 7 comments
Open

How do you use this to run docker commands? #735

mmkk20158 opened this issue Feb 14, 2024 · 7 comments
Labels

Comments

@mmkk20158
Copy link

So I installed this on my docker server and i'd like people to be able to restart a service on another docker. obviosly since this is inside a docker itself it doens't have access to the hosts info.

basically i'm hosting a palworld server and i want my users to be able be able to restart the docker container for updates / mods / etc

@bugy
Copy link
Owner

bugy commented Feb 15, 2024

Hey, i guess this is not a question about script server, but rather docker and container management. Your goal is to write a script which will work inside a docker container. Script server will just give a web access to this script.
I think this guide might be helpful https://www.reddit.com/r/docker/comments/169hnti/quick_guide_how_to_control_a_docker_host_from/

@mmkk20158
Copy link
Author

hey thanks! yeah i know i can use the api but was just curious if there was some other way without opening a port.

thanks again!

@bugy
Copy link
Owner

bugy commented Feb 16, 2024

Yep, unfortunately Script server doesn't have any special features for docker

@bugy bugy added the question label Feb 16, 2024
@mmkk20158
Copy link
Author

Yep, unfortunately Script server doesn't have any special features for docker

what's the recommended way to add curl to the container? i tried a volume binding but then all of the dependancis aren't there

@mmkk20158
Copy link
Author

mmkk20158 commented Feb 17, 2024

I just used the python3 that was included ayway, for anyone in the future

#!/usr/local/bin/python3
import http.client


palworld_container = "71cc9de67538"
docker_host = "172.17.0.1"
docker_port = 2375

restart_path = f"/containers/{palworld_container}/restart"

print("connecting to docker host...")
connection = http.client.HTTPConnection(docker_host, docker_port, timeout=100)

print(f"REST API call: POST {restart_path}")
connection.request("POST", restart_path)
response = connection.getresponse()

print("Resonse:")
if ( response.status == 204):
    print("Success")
else:
    print(f"{response.status}    {response.reason}")

@bugy
Copy link
Owner

bugy commented Feb 20, 2024

Thanks a lot @mmkk20158 !

@agail
Copy link

agail commented Apr 15, 2024

Yep, unfortunately Script server doesn't have any special features for docker

what's the recommended way to add curl to the container? i tried a volume binding but then all of the dependancis aren't there

You could use a staging script* once the container is up to install additional packages or customize your image with docker compose to add the packages you need.

#!/bin/bash
# placed at shared directory with the container

apt update
apt install package1 package2 package3
apt clean

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

No branches or pull requests

3 participants