How to use Dockerfile?
This file contains user commands which will be needed to build an image. This is the simplest way that I can explain this. For more information please follow the Dockerfile reference guide
The following image shows a sample Dockerfile that I created to build an image with php. I will explain line by line.
- FROM php:7.4.4-apache - This is where you define what image you will be using to build a custom image
- COPY site1/ /var/www/html - This is will copy the local path content to remote path (to container)
- EXPOSE 80 - This is where you define which port should be exposed
After creating a Dockerfile now you can build the image.
docker build -t somename #this command is to build an image with the given tag name
After a successful run when I brows in to the docker host, it shows the content in the php file that I kept in site path.
docker-compose
In simple terms its an tool to run multiple container docker application. For example you have a php and a MySQL container and you want to run from a single command, docker-compose is the best way. Its an orchestrator and you have to define every thing on an YAML file.
The following image shows the docker-compose.yml file that I created for this post. You can do much more and this is just a basic one and please do refer the documents of docker for more.
Now you can run with docker-compose up command.
From the video you can see I am running both php and a mysql container from a single command. Below image shows the phpinfo file which is in the php container. How cool is this. you can do many fun stuffs and experiments while you prototyping and you can do more complex things. Lets run a docker ps command to check which containers are running.
Clearly its showing that php and mysql containers are running with its own exposed ports.
Comments
Casino Games - Play the most exciting slots and casino 코인갤 games. ➤ Casino Games & More 벳썸 도메인 at BonusBetsSites777.com. Claim 페이 백 먹튀 Welcome 복불복 룰렛 Bonuses ✓ Free 강원랜드후기 Spins for Desktop & Mobile.