Let's follow the steps to create more complex docker images:
- frontend - wordpress image
- backend - mysql image
First, we just start a docker images with Multipass.
PS> multipass launch docker -n kiko
Login to docker (kiko) and start creating docker-compose.yaml.
PS> multipass shell kiko
ubuntu@kiko:~$ mkdir blog && cd blog
ubuntu@kiko:~/blog$ vi docker.compose.yaml
---------------------------------------------------
version: "3"
services:
frontend:
image: wordpress
ports:
- "8089:80"
depends_on:
- backend
environment:
WORDPRESS_DB_HOST: backend
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: "coffee"
WORDPRESS_DB_NAME: wordpress
networks:
dmz:
ipv4_address: "192.168.33.89"
backend:
image: "mysql:5.7"
environment:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: "coffee"
volumes:
- ./mysql:/var/lib/mysql
networks:
dmz:
ipv4_address: "192.168.33.90"
networks:
dmz:
ipam:
driver: default
config:
- subnet: "192.168.33.0/24"
----------------------------------------------------
ubuntu@kiko:~/blog$ docker-compose up -d
ubuntu@kiko:~/blog$ docker-compose ps
ubuntu@kiko:~/blog$ docker network ls
ubuntu@kiko:~/blog$ docker inspect blog_dmz
http://kiko.mshome.net:8089/ |
Links:
- Docker Compose 101