So I tried to launch an existing
Wordpress site with
docker and failed.
Well, didn't manage to get it to work perfectly cause I realise I needed to enable
But it can load the homepage fine.
So my initial plan was to create a single image that acts like a VM. Terrible idea, but not impossible.
Theoretically, you can
docker run -it imagename bash and run all the mundane setup like you would on a server. Then you need to
docker commit the changes to an image.
You'll need to
Wordpress folder in
/var/www/html and write a script to import the db. In theory, it should work. But the container would probably exit after it ran it's stuff cause that's what
Docker containers are meant to do. They run stuffs and close.
This is the bad example with a "VM" approach: https://github.com/resting/docker-ubuntu-lamp
So it consists of only a single
Dockerfile. This version doesn't load any
This is a better version, using
docker-compose to have 2 separate containers: https://github.com/resting/docker-ubuntu-lamp/tree/better-example
So the better version will take a
db folder and import it in the
db container under the database name of the
argument passed in
php service consists of both
It will take
./html folder and replace
/var/www/html in the container.
Do note you should change
wp-config.php settings to match
db. So your host should be
define('DB_HOST', 'db'); instead for example. The password should match the arguments passed in your
If you do
docker-compose up you should be able to see your site at
localhost:8000. That's all I have about launching
However, I didn't fix the
modrewrite issue cause I realise I need a VM (hence,
Vagrant), rather than creating more and more images.
Docker doesn't persist any state unless you commit the state to an image.
I should probably break
PHP into their own containers too, but its too much work for what I need to do.
If you look into
docker-entrypoint.sh file of the
Dockerfile, https://github.com/docker-library/mysql/tree/6b1dc54320b03b83a89068f49cc796fea0ff6bb4/5.7, you'll get a rough idea of how much scripting you'll need to setup your own image.
Dockerfile is here for reference: https://github.com/docker-library/php/tree/66a746410bf607ce9b41046e2b42a619fc71d272/7.0/apache
As you can imagine, if you need to swap out the pieces, for example
MYSQL, to test your app, then
Docker is the way to go, though it'll probably take some time to create the custom images. But for me, I just need a small environment to do my testing,
Vagrant is the way to go for me.