Docker run
- docker | |
- www | |
- app1 | |
- app2 | |
- config | |
- nginx | |
- logs | |
- nginx | |
- data | |
- mariadb | |
docker run -itd \ | |
--restart unless-stopped \ | |
--name nginx \ | |
--network backend \ | |
-p 80:80 \ | |
-p 443:443 \ | |
-v ~/docker/www:/var/www \ | |
-v ~/docker/config/nginx:/etc/nginx/conf.d \ | |
-w /var/www \ | |
nginx:alpine | |
docker run -itd \ | |
--restart unless-stopped \ | |
--name php \ | |
--network backend \ | |
-v ~/docker/www:/var/www \ | |
-w /var/www \ | |
php:fpm-alpine | |
docker run -itd \ | |
--restart unless-stopped \ | |
--name mariadb \ | |
--network backend \ | |
-e MYSQL_ROOT_PASSWORD=secret \ | |
-e MYSQL_DATABASE=dbname \ | |
mariadb | |
# PHP Extensions | |
docker-php-ext-install pdo_mysql | |
docker-php-ext-install opcache | |
# Not confirmed if it is necessary | |
sysctl net.ipv4.conf.all.forwarding=1 | |
iptables -P FORWARD ACCEPT | |
# Problems to solve | |
folders permissions - maybe using the same user/group when running the container | |
auto install some extensions inside php container - exists a faster solution than creating a custom Dockerfile? | |
# Alias / Functions | |
composer () { | |
tty= | |
tty -s && tty=--tty | |
docker run \ | |
$tty \ | |
--interactive \ | |
--rm \ | |
--user $(id -u):$(id -g) \ | |
--volume /etc/passwd:/etc/passwd:ro \ | |
--volume /etc/group:/etc/group:ro \ | |
--volume $(pwd):/app \ | |
composer "$@" | |
} | |
npm () { | |
tty= | |
tty -s && tty=--tty | |
docker run \ | |
$tty \ | |
--interactive \ | |
--rm \ | |
-w /usr/src/app \ | |
--user $(id -u):$(id -g) \ | |
--volume /etc/passwd:/etc/passwd:ro \ | |
--volume /etc/group:/etc/group:ro \ | |
--volume $(pwd):/usr/src/app \ | |
node:alpine npm --no-cache "$@" | |
} | |
php () { | |
tty= | |
tty -s && tty=--tty | |
docker run \ | |
$tty \ | |
--interactive \ | |
--rm \ | |
-w /usr/src/app \ | |
--user $(id -u):$(id -g) \ | |
--volume /etc/passwd:/etc/passwd:ro \ | |
--volume /etc/group:/etc/group:ro \ | |
--volume $(pwd):/usr/src/app \ | |
php:alpine "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment