Yii and Docker
Yii and Docker

Yii and Docker

For development and deployments Yii applications can be run as Docker containers. A container is like a lightweight isolated virtual machine that maps its services to host's ports, i.e. a webserver in a container on port 80 is available on port 8888 on your (local)host.

Containers can solve many issues such as having identical software versions at developer's computer and the server, fast deployments or simulating multi-server architecture while developing.

You can read more about Docker containers on docker.com.


  • docker
  • docker-compose

Visit the download page to get the Docker tooling.


After installation, you should be able to run docker ps and see an output similar to


This means your Docker daemon is up and running.

Additionally run docker-compose version, your output should look like this

docker-compose version 1.20.0, build unknown
docker-py version: 3.1.3
CPython version: 3.6.4
OpenSSL version: OpenSSL 1.1.0g  2 Nov 2017

With Compose you can configure manage all services required for your application, such as databases and caching.



Basic commands for Docker are

docker-compose up -d

to start all services in your stack, in the background

docker-compose ps

to list running services

docker-compose logs -f

to view logs for all services, continuously

docker-compose stop

to stop all services in your stack, gracefully

docker-compose kill

to stop all services in your stack, immediately

docker-compose down -v

to stop and remove all services, be aware of data loss when not using host-volumes

To run commands in a container

docker-compose run --rm php composer install

runs composer installation in a new container

docker-compose exec php bash

executes a bash in a running php service

Advanced topics

Yii framework tests

You can run the dockerized framework tests for Yii itself as described here.

Database administration tools

When running MySQL as (mysql), you can add phpMyAdmin container to your stack like the following:

        image: phpmyadmin/phpmyadmin
            - '8888:80'
            - PMA_ARBITRARY=1
            - PMA_HOST=mysql
            - mysql

Заберите ссылку на статью к себе, чтобы потом легко её найти!
Раз уж досюда дочитали, то может может есть желание рассказать об этом месте своим друзьям, знакомым и просто мимо проходящим?
Не надо себя сдерживать! ;)

Старт! MoonВase — A Hot Start on the Internet
Старт! MoonВase — A Hot Start on the Internet
Старт! Menu