linux programming web server

Simple Laravel Docker setup

composer create-project laravel/laravel laravel-app
cd laravel-app
touch .docker/Dockerfile
touch .docker/vhost.conf

Content of Dockerfile:

FROM php:7.3-apache
COPY . /srv/app
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data /srv/app && a2enmod rewrite

Content of vhost.conf:

<VirtualHost *:80>
    DocumentRoot /srv/app/public
    <Directory "/srv/app/public">
        AllowOverride all
        Require all granted
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Building image:

docker build --file .docker/Dockerfile -t laravel-app .

Running container:

docker run --rm -p 8080:80 laravel-app

Source: BitPress

programming web server

Docker Compose

Compose is a tool for defining and running multi-container Docker applications. With Compose, you can use YAML file to configure your application’s services. Then, with a single command, you can create and start all the services from your configuration.

  • define your app’s environment with Dockerfile
  • define services (containers with additional stuff) that make up your app in docker-compose.yml
  • run docker-compose up so Compose can start and run your entire app


docker-compose ps
docker-compose up -d
docker-compose stop
docker-compose down
docker-compose rm [name]
docker-compose build [name]
or docker-compose build --no-cache
docker-compose up -d
docker-compose logs --follow [service_name]
docker-compose exec [service_name] [command]

Source: freeCodeCamp

linux programming web server


Containerization is the process of encapsulating software code along with all of its dependencies inside a single package so that it can be run consistently anywhere. Docker is an open source containerization platform. It provides the ability to run applications in an isolated environment known as a container.

Containers are lightweight virtual machines that can run multiple containers simultaneously. Containers can be deployed on servers.

Images are multi-layered self-contained files with necessary instructions to create containers. Containers are runnable instances of images. If we compare images with classes from OOP then containers are the objects. Images are stored in registries such Docker Hub, the default public registry for storing images.

Arch install

pacman -Sy docker docker-compose
systemctl start docker.service
gpasswd -a benke docker
docker info

Images commands

docker images
docker image ls
docker rmi [image_id]
docker run [image_id]
docker create [image_id]
docker start [container_id]
docker run [image_id] -d
docker pull [image_id]

Containers commands

docker run -it docker/whalesay cowsay Petar
docker run -it -p 80:80 nginx
docker ps
docker ps -a
docker container ls
docker start [container_id]
docker restart [container_id]
docker exec [container_id] [command]
docker logs [container_id]
docker stop [container_id]
docker rm [container_id]
docker container rm --force [container_id]
docker system prune
docker inspect [container_id] (look for RestartPolicy in the output)
docker update --restart=no [container_id]


  • FROM
  • COPY
  • RUN
  • CMD

Source: freeCodeCamp


WordPress u Docker-u

Podrazumeva se da na računaru imamo instaliran funkcionalan Docker.

Najpre kreiramo direktorijum za naš projekat. U tom direktorijumu kreiramo fajl docker-compose.yml sa sledećim sadržajem:

version: '3.3'
        image: mysql:5.7
            - db_data:/var/lib/mysql
        restart: always
            MYSQL_ROOT_PASSWORD: secret
            MYSQL_DATABASE: wordpress
            MYSQL_USER: wordpress
            MYSQL_PASSWORD: wordpress
            - db
        image: wordpress:latest
            - "8000:80"
        restart: always
            WORDPRESS_DB_HOST: db:3306
            WORDPRESS_DB_USER: wordpress
            WORDPRESS_DB_PASSWORD: wordpress
            WORDPRESS_DB_NAME: wordpress
    db_data: {}

Zatim sledi pokretanje kontejnera:

docker-compose up -d

Sada u brauzeru možemo da otvorimo adresu http://localhost:8000 i da instaliramo WordPress.

Ako želimo da pristupimo WordPress instalaciji, kucamo:

docker-compose exec wordpress bash

Ako želimo da pristupimo bazi podataka, kucamo:

docker-compose exec db bash
mysql wordpress -u wordpress -p

Izvor: Hostinger