Docker is an open-source project for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises. Docker is also a company that promotes and evolves this technology, working in collaboration with cloud, Linux, and Windows vendors, including Microsoft.
In this short tutorial we're going to containerize a simple PHP laravel application.
- Create the Application
- Go to the folder "cd docker-laravel"
- Run Locally "php artisan serve"
- Next we write the Dockerfile, this is a set of commands the docker engine uses to build the image.
FROM php:7.4.15-fpm-alpine3.13
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /SRC
COPY . /SRC
RUN composer install
EXPOSE 8000
CMD php artisan serve --host=0.0.0.0 --port=8000
"FROM php:7.4.15-fpm-alpine3.13" is the image that your docker image is based on.
Second command downloads and install Composer on the base image
Third Command specifies working directory, where the code will be in the image and container.
Fourth command will copy files from your present working directory to /SRC folder
Fifth command runs the command Composer Install
Sixth command allows access to the app on port 8000
Seventh command starts the server.
Top comments (0)