I have found this, but it does not work for me.
My (really) simple docker-compose.yml
:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: example
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
Starting:
docker-compose up
After made some change to containers (install plugins and themes on wordpress).
docker-compose stop
docker commit main_mysql_1 test-mysql
docker commit main_wordpress_1 test-wordpress
docker save test-mysql > test-mysql.tar
docker save test-wordpress > test-wordpress.tar
Save the two tar files on another machine and load them:
docker load -i ./test-mysql.tar
docker load -i ./test-wordpress.tar
Now change the docker-compose.yml
to:
version: '3.1'
services:
wordpress:
image: test-wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: example
mysql:
image: test-mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
But the container started is wordpress from scratch. Nothing of work done (plugin, themes, etc) was preserved.
What is my mistake? I don't want to use online repository for these private purposes.. Could you suggest a more simple and powerful procedure for pass container between two hosts?
A workaround with volumes:
version: '3.1'
services:
wordpress:
container_name: GREB_wordpress
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: example
volumes:
- ./www:/var/www/html
mysql:
container_name: GREB_mysql
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
- ./mysql_data:/var/lib/mysql