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.
dockerdocker-composeVisit the download page to get the Docker tooling.
After installation, you should be able to run docker ps and see an output similar to
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 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
You can run the dockerized framework tests for Yii itself as described here.
When running MySQL as (mysql), you can add phpMyAdmin container to your stack like the following:
phpmyadmin: image: phpmyadmin/phpmyadmin ports: - '8888:80' environment: - PMA_ARBITRARY=1 - PMA_HOST=mysql depends_on: - mysql Found a typo, or you think this page needs improvement?
Edit it on GitHub !
Signup or Login in order to comment.