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

Updating docker image with out losing data #15

Open
babyheysus opened this issue May 24, 2020 · 7 comments
Open

Updating docker image with out losing data #15

babyheysus opened this issue May 24, 2020 · 7 comments

Comments

@babyheysus
Copy link

Very new to this but I've hit a wall and need help.
Using docker via Synology (DS918+), downloaded the image while on 1.4.0.3. Hosted Terraria Vanilla for quite a while and then 1.4.0.4 releases... I have the latest image but I'm not too sure how to proceed in terms of updating the 1.4.0.3 container and/or pulling the world file out and pushing it back into a new container. Note: I did not use the generate world line below:

sudo docker run --rm -it -p 7777:7777 \
    -v $HOME/terraria/config:/config \
    --name=terraria \
    beardedio/terraria

and just installed it via Synology Docker. The only thing I altered was the port options (didn't find luck with ports but using the "Use the same network as Docker Host" option worked perfectly) and changed the volume path for the config files.

Have installed Putty. Tried the line:

sudo docker run --rm -dit \
--name=terraria \
-v $HOME/path/to/where/config/is/config \
-e world=1.4.0.3 \
-p 7777:7777 \
beardedio/terraria

as mentioned in the How to: section using the same 1.4.0.3 config file and with the same world name. Outputs a string of numbers and letters then nothing. Docker briefly shows the new container but that dies after a few seconds and does not exist. During this time, the container is off.
Also tried exporting the container which holds my world but cannot locate the personal world file within.

ELIA5:
1.0. How to update the outdated container currently on 1.4.0.3 without deleting the world. Have not attempted clearing the container as it says it'll delete everything.
1.1. Why is the code above not working? It runs but then the new container dies after. Typo? And
2.0. How to locate the world.wld file within the container? For backup purposes.

Any help/guidance/tips will be appreciated!

@kevinkjt2000
Copy link

kevinkjt2000 commented May 24, 2020

I don't know much about your exact setup, but this line is wrong without the :/config

-v $HOME/path/to/where/config/is/config \

it should be

-v $HOME/path/to/where/config/is/config:/config \

I'd also recommend using a tagged version of the docker container beardedio/terraria:vanilla-1.4.0.4

@babyheysus
Copy link
Author

I don't know much about your exact setup, but this line is wrong without the :/config

-v $HOME/path/to/where/config/is/config \

it should be

-v $HOME/path/to/where/config/is/config:/config \

I'd also recommend using a tagged version of the docker container beardedio/terraria:vanilla-1.4.0.4

Thanks for the response! Unfortunately, doing so gets an error response from daemon, bind mount failed. Saying the path doesn't exist. Without the " :/ ", the line does execute unless I'm wrong to assume its the config.json file? Upon creating the container, I've created a volume path to "$HOME/path/to/where/config/is/", where the log file and server config files are. Tried running in root as well to no avail.

A question from that, what does ":/" do?

@kevinkjt2000
Copy link

The : separates the host path from the container path in the -v /path/on/host/machine:/path/inside/docker/container. You may read the documentation for more information.

https://docs.docker.com/engine/reference/run/#volume-shared-filesystems
https://docs.docker.com/storage/volumes/

@Noutbuk
Copy link

Noutbuk commented May 27, 2020

The standard path of the world folder inside the docker container is /root/.local/share/Terraria/Worlds/.

As a first step, I recommend the following: If you successfully mounted the config directory (/config inside the container), you can copy the world file to the config directory. Since this is mounted, the world file is now accessable from within and without the container (e.g. for backup purposes).

You can now use the environment varible world to set the world. This assumes, that the world file is located in the /config folder. See https://github.com/beardedio/terraria#usage and https://www.synology.com/en-global/knowledgebase/DSM/help/Docker/docker_container step 5. "Environment".

To update to a new version, you should backup the content of the mounted /config directory, which will now contain the world as well.
Then you can update the container without loosing any data. To do so, maybe this link may help: https://community.synology.com/enu/forum/1/post/123646

@Nightreaver
Copy link

I just wonder, how did you manage to keep the server running even tho there is no stdout, it was failing for me all the time?

@babyheysus
Copy link
Author

babyheysus commented May 29, 2020

Firstly, thanks for the response! I've been away from my server so I couldn't attempt anything for a while.

The standard path of the world folder inside the docker container is /root/.local/share/Terraria/Worlds/.

So, yep, /root/.local/share/Terraria/Worlds/ looks like the place to be, however, I've looked at it through the exported container and only favourites.json lives there. And doing a search of the entire directory doesn't have anything with my world name.

Additionally, using cd /root/.local/ doesn't work since it doesn't exist in my case.

As a first step, I recommend the following: If you successfully mounted the config directory (/config inside the container), you can copy the world file to the config directory. Since this is mounted, the world file is now accessable from within and without the container (e.g. for backup purposes).

I think I'm missing something. /config is a folder within the container that I'm not seeing?... As mentioned earlier, I assumed it was the config.json file considering nothing else was named config. Now I've had a hunt through Putty and now I'm inside the container folder through using docker info and cding all the way to its directory. I've now only got this left to enter:

image

Not sure how to enter those "." folders but is it here somewhere?

You can now use the environment varible world to set the world. This assumes, that the world file is located in the /config folder. See https://github.com/beardedio/terraria#usage and https://www.synology.com/en-global/knowledgebase/DSM/help/Docker/docker_container step 5. "Environment".

Continuing from the previous paragraph, in the Environment Variables container, the path is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin which is very weird and, again, can't seem to find this directory. /config may live here? Changing this path ruins the container, making it unable to start the TerrariaServer.exe so this maybe what I'm looking for? (if I can access it)

To update to a new version, you should backup the content of the mounted /config directory, which will now contain the world as well.
Then you can update the container without loosing any data. To do so, maybe this link may help: https://community.synology.com/enu/forum/1/post/123646

This actually just cleared everything and doing so, made it like I've just installed another container. Importing the exported container and running it shows no signs of the previous world sadly. Which may mean the world file is living somewhere else? Or exporting the container doesn't really back up anything and only exports the image...

I've exported everything so I may be okay if we find a solution but if it's the worst-case scenario - all good. I've played Terraria 4 times over in the past and I just can't stop 😅. I've also used a known seed so should be okay. Anywho, I'd still really like to figure this out before another update so I've made another world as a stand-in.

@babyheysus
Copy link
Author

I just wonder, how did you manage to keep the server running even tho there is no stdout, it was failing for me all the time?

Not sure what you mean considering after making the container, the typical TerrariaServer prompts appeared in the Terminal section once running (takes like 20 seconds or I just type jibberish and it pops up since I entered an invalid input). The Log tab also shows all the outputs too.

All I did was:

  1. Installer Docker via Synology's Package Center
  2. Searched for beardedio's image in the Registry Tab within Docker
  3. Launched the image and allowed high privilege, changed the container name, volume mount & network settings.
  4. Ran the container and profit.

@hskrtich hskrtich changed the title Updating to latest image (1.4.0.3 to 1.4.0.4?) Updating docker image with out losing data Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants