So almost everyone I know of is working on getting their solution onto Docker. I will not be talking about Docker in here today; there are tons of blogs and published content around that subject.
What I will be talking about is how to fire-up a WordPress website in minutes using Docker.
- You will need a linux server – I use nothing but Ubuntu 14.04 LTS
- You will need to have docker-compose installed in your system. If you don’t have it, you can install it using pip:
1$ sudo pip install docker-compose
- You will need to have a docker-compose file. I’ve included mine in here for your reference:
wordpress: image: wordpress container_name: wordpress hostname: wordpress links: - mysql:mysql ports: - "8080:80" mysql: image: mariadb environment: MYSQL_ROOT_PASSWORD: a_sophisticated_password_here nginx: image: nginx container_name: nginx hostname: nginx volumes: - ./nginx:/etc/nginx ports: - "80:80" links: - wordpress:wordpress
- If you notice, in my nginx section I’ve added a volumes line. What this does is I’m telling the container to map my nginx directory relative to the current path in the host to the container’s /etc/nginx directory. What my nginx directory contains is just the default files/directories of the nginx image. I just copied them to the host so I can modify it directly. You don’t really have to do this it’s just my preference.
- You should modify your nginx configuration related to your new wordpress website.
- Once you have everything setup, just run the following command:
$ docker-compose up
- This will start up the process of pulling all of the images you have defined in your docker configuration file. Once all images are up, the containers will be started.
- Once you validated that everything is working, it’s time to start the docker containers in the background. Exit your current session by hitting Ctrl-C.
- Start docker-compose again in background mode:
$ docker-compose up -d
- And that’s all she wrote.
I hope you learn something from this and try spinning some docker images on your own. My recommendation, try to spin up a MediaWiki website.
Hit me up with your comments.