You need to install docker. !!! ATTENTION DOCKER RUN ON HYPER-V ==> VIRTUALBOX WILL STOP WORKING !!!
In this first versions we use the dockerfile for building images. We need to build php an mysql image for this moment. Built images will be uploaded to docker hub.
- When i tried docker I built one image at a time. (comment or cut temporary lines after
FROM
) COPY src/ /var/www/html
src is the directory where we have all the code of git repoADD dbsetup.sql /docker-entrypoint-initdb.d
we need to have the dbsetup.sql file in the same directory of dockerfile this will initialize the image with the DB. Done at build time for persistency.
docker build -t php_img .
- t is for tagging the image to be built
- . is the directory of docker file in this case the current directory
Here we use docker compose to make containers running from built images that will be pulled up from docker hub. in the future we can try to build images from composer...
setup your username and password before doing pull push operations
docker pull -a <username>/<repository>
- -a for pulling al tagged images
First you need the docker-compose.yml file for running containers. It need to be in the directory where you're launching command.
docker-compose up
docker tag image_id yourhubusername/repository:tag
docker tag bb38976d03cf sordinho/digital_student_record:mysql
docker tag 34d1d5d2bbbc sordinho/digital_student_record:php
docker push yourhubusername/repository
docker push sordinho/digital_student_record
-
List containers
docker ps -a
-
List images
docker images
-
Remove containers
docker rm $(docker ps -a -q)
-
Remove images (-f force)
docker rmi -f $(docker images -q)
-
Execute bash into a container
docker exec -it DOCKER_CONTAINER_ID bin/bash
- You need the docker-compose.yml file
docker pull -a sordinho/digital_student_record
Pull the imagesdocker-compose up
Run containers- Visit localhost and pray it's running