Move docker container and its database container to another server - docker

I have an odoo:13 container and its corresponding postgres container running in a server. I want to move them to a test server so my test server's data be similar to my original server. how can I do it? I have mounted volumes by the way. (I created docker volumes)

As you have already mounted the data on to volumes, you will be able to start the containers on a new server using the same docker images using the backup from the old container.
Refer the official guide for backup-restore-or-migrate-data-volumes.

Related

Move a running container along with the data produced by the container

I'd like to ask a question about how to dynamically move a running container along with the data produced by the container. I understand that the image of a docker container can be created and moved to other places, and docker volumes allow me to obtain data produced by a container on host machine. Here is my question. Assume that I have a container running that performs an iterative calculation and writes results to a docker volume after each iteration, and I want to move the container along with intermediate results (whatever is available in the docker volume) to a remote host machine that has a docker engine. After migration I will load the saved docker image and data to continue the calculation on the remote host machine. The command "docker save" allows me to get the image of the container, and the intermediate results produced by the container can be accessed from the docker volume on host machine. However, how do I know if the container is writing data when I read data from the docker volume? In other words, how to avoid concurrence of writes and reads in this case? Thanks in advance.

Nextcloud Container and external hdd

im fairly new to the Docker Container world and im trying to move my Nextcloud server to the container.
i can deploy it successfully on a test environment, but im trying to map an externall HDD that will eventually contain all of the data (profiles/pics/data/etc) as it is on my current server.
my current setup is an ubuntu server 20.04.1 and Nextcloud 18 with an external HDD mounted for storage.
so far i havent been able to map the external drive.
can anyone provide any insights?
Regards!
To help you specifically, more information is required, like which docker image are you using and how are you deploying your container. Also, this might be a question for https://serverfault.com/
The general concepts of "mounting" parts of a filesystem into a container are described at Docker Volumes and Bind Mounts.
Suppose your harddrive is mounted at /mnt/usb on the host, you could access it within a docker container at /opt/usb when started like this
docker run -i -t -v /mnt/usb:/opt/usb ubuntu /bin/bash

Putting databases in their own Docker containers?

I run a complex app with a database backend and many other things all in one container. I notice that Docker images for different database systems are available. When would I want to move something like a DB server to its own container, instead of running everything in the same container? The advantage I have now is that I can deploy everything at once, and I don't have to configure more than one container to get things talking.
Docker or the Container Manager is using Linux container technology to provide a best abstraction, using docker container with multiple process is a bad idea; use docker container for isolating one process, use docker volume container for storing database data ( docker state is not persistent by default).
Use docker-compose or fig to attach two docker containers db and web app, it will ease your management in future!

How to move an application based on two linked docker containers to another host?

I'm looking forward to moving an application based on two linked contianers to a different host. The first container comes from an official MySQL image. The second container comes from an official Wordpress image. WP container is linked to the MySQL container.
These containers have evolved over time. Different templates and data. I'd like to migrate the containers to another host. Right now, if I stop the containers I only have to issue a docker start mysql and a docker start wp and all the context (links, ports, config, wahtever...) is maintained. I don't have to specify which ports I expose, or what links are in place.
What I would expect, and I don't know if docker offers, is to:
export the containers
move them to the new host
import the container in the new host
in the new host issue a docker start mysql and a docker start wp
Is this possible? If not what would be the way to get the exact same infraestructure up and running in another host?
I have tried using export/import and save/load. In both cases what you get imported is an image, not a container.

How to persist Docker data in HOST

Having a docker database container, in this case a neo4j container, how can I persist the data, and make sure that the next time I start a neo4j docker image that it points to my HOST database and not a new database?
I am using Docker in windows, so boot2docker is being used. And I say database but I am also thinking how do I serve a directory that I am working on a web application to be run, so I don't have to commit all the changes to the image... I just want to edit a folder in my windows environment and debug it using a docker web server stack.
The easiest way would be to have a shared folder between your Windows host and boot2docker VM (This post can help)
Then you just have to share that folder to your container using the -v option.
docker run -d -v /path/to/shared/folder/in/VM:/path/to/folder/in/container myimage /cmd
More info on how to share data between container and host

Resources