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

Connecting to the running Server #74

Open
ghost opened this issue May 7, 2021 · 2 comments
Open

Connecting to the running Server #74

ghost opened this issue May 7, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented May 7, 2021

Hi, great work! I was wondering if after starting the docker container as a background process there is any way to access the shell again?
Normally if I run it without setting it to run in the background I can enter commands like "save", "exit", and "kick", and I would like to be able to use this access without having to have it running in the foreground the whole time.

@ghost
Copy link
Author

ghost commented May 7, 2021

So as an update, before asking my question, I thought that docker attach was what I was looking for, but when I used it, I just got a blank console, so I was confused.
Now I tried again, and then logged into the server with Terraria, and realized that I actually am getting the server output, but I can't enter any commands:

$ sudo docker attach terraria
help
exit
<ip address> is connecting...
Debug: GetDataHandlers / HandlePlayerBuffList handled event and sent data <Username>
<Username> has joined.

So help and exit did nothing, but I saw all of the server info. Is there any way that I could enter commands here?

@ronelm2000
Copy link
Contributor

You can detach from an interactive Docker session without exiting the container. You “daemonize” the container. The effect will be, as if you had started it with the -d flag in the first place.

You have to use two combinations, one after the other: ctrl+p followed by ctrl+q. You turn interactive mode to daemon mode, which keeps the container running but frees up your terminal.

You can attach to it later using docker attach, if you need to interact with the container more.
From: https://vsupalov.com/exit-docker-container/

So the idea is you start in interactive mode with sudo docker run -it -p 7777:7777 -v $HOME/terraria/world:/root/.local/share/Terraria/Worlds --name="tshock" --log-opt max-size=200k ryshe/terraria:latest, detach using Ctrl+P and Ctrl+Q, then access it back again with sudo docker attach tshock.

Personally, this should be in documentation since not everyone is too familiar with docker, but it is what it is.

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

No branches or pull requests

1 participant