How to migrate an existing service docker?

I don’t know if this is the right place to ask this and I am a newbie when it comes to Docker. I have 2 existing WordPress websites that I want to “dockerify.”

Since I have a specific version of WP for the website and GIT, it is not a problem for me to store the website’s code (theme files, plugins etc). But I don’t know how to handle assets and database migrations. Should I create a docker image and then copy all the files into docker? Or should I store them in the registry also?

  • Kubernetes locally via Docker: why do we need port forwarding?
  • Docker Detached Mode
  • How to deal with files of web applications in docker?
  • Docker run results in “host not found in upstream” error
  • How to correctly configure docker daemon listen on port, in Ubuntu16.04?
  • Why Jenkins not stored data?
  • For database, I know that I can create an SQL file, which will be very small in size and just add the migration to Dockerfile and maybe create an automated script that will export SQL file and push it to the repository. But I don’t want to store High-res image files in GIT.

    I think my problem arises from a single concern. Can I trust docker? Are docker containers persistent? Let’s say a container got terminated. Will I lose all my work? Or can I just run it again like in vmware virtual machines?

    If it matters, I am using Gitlab for GIT, CI, and Registry.

  • File permission error when installing Meteor in Docker
  • Marathon treats healthy tasks as unhealthy and kills them
  • How to configure Docker in windows to listen to tcp?
  • Cannot start mysql or mysqld_safe on ubuntu
  • Unable to reach Bash Shell on 'docker attach'
  • How to delete unused docker images in swarm?
  • One Solution collect form web for “How to migrate an existing service docker?”

    Seems like you should play around with Docker a bit if you want to gain confidence in it. There is no reason your WP site shouldn’t be fine using Docker if it’s set up properly. I would start with images from the official WP Docker repository as they are pretty good and will save you headache otherwise.

    Sounds like what you would want to do is use a persistent volume for your files, e.g. you would include something like this in your docker run statement: -v /var/wp/blog/wp-content:/var/www/html/wp-content which you could sync with your Git repo. This lets you abstract your code from WP itself. To update WP all you do is recreate the WP container with the new version and your files are not touched. You would want to use a separate MySql server — either in another Docker container or otherwise, basically anything the WP instance can access.

    Managing images is separate topic really, but you might want to look into a CDN for those which can be managed via various WP plugins and would not only be faster in most cases, it makes it easier to manage when they are all in one place.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.