Skip to content

Instantly share code, notes, and snippets.

@lparolari
Created December 3, 2018 17:11
Show Gist options
  • Save lparolari/362c9c3356f67f0ccd3f6b73e8302312 to your computer and use it in GitHub Desktop.
Save lparolari/362c9c3356f67f0ccd3f6b73e8302312 to your computer and use it in GitHub Desktop.
Docker and Docker-Compose memo

Docker and Docker-Compose memo

Luca Parolari <luca.parolari23@gmail.com>.

For now, I will not explain all the things on docker. This memo is thought to integrate docker in a project with the minimal number of steps.

Docker

Docker is a mechanism used to create isolated environment without setting up a virtual machine.

How to

Docker uses a Dockerfile to get the informations of how the environment is. There you can specify all the options of the "venv", setting up parameters and decide what will the environment has to contain.

The dockerfile can be like this

FROM php:7.2-apache

MAINTAINER Luca Parolari

COPY . /srv/app
COPY .docker/php/vhost.conf /etc/apache2/sites-available/000-default.conf

EXPOSE 80

RUN chown -R www-data:www-data /srv/app && a2enmod rewrite

Build

To run the environment, it must be built.

docker build --file .docker/php/Dockerfile -t php-lapieve-docker .

Run

docker run --rm -p 8080:80 php-lapieve-docker

Docker-Compose

Docker-Compose is an extension of docker that allows to build and run docker in the composer style.

How to

Create a docker-compose.yml like this

version: '3'
services:
 app:
  build:
   context: .
   dockerfile: .docker/php/Dockerfile
  image: php-lapieve-docker
  ports:
   - 8080:80
  volumes:
   - ./:/srv/app

Run

docker-compose up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment