My dockerfile
FROM php:7.0-apache
RUN pecl install -o -f redis
RUN pecl install -o -f xdebug
RUN docker-php-ext-enable redis
RUN docker-php-ext-enable xdebug
RUN docker-php-ext-install pdo pdo_mysql mysqli
RUN apt-get update
RUN apt-get install locales-all -y
My docker-compose file
version: "3.7"
services:
redis:
restart: unless-stopped
image: redis:alpine
container_name: redis_mp
volumes:
- redis-data:/data
# if we need a custom redis configuration
# - ./docker//usr/local/etc/redis/redis.conf:/usr/local/etc/redis/redis.conf
mysql:
restart: unless-stopped
image: mysql:5.6
container_name: mysql_mp
command: --default-authentication-plugin=mysql_native_password
ports:
# So you can use a database client on your host machine
- 3306:3306
environment:
- MYSQL_ROOT_PASSWORD=secret
volumes:
- mysql-data:/var/lib/mysql
# if we need a custom mysql configuration
# - ./docker/etc/mysql/conf.d:/etc/mysql/conf.d
apache:
restart: unless-stopped
# image: php:7.2-apache
build: ./docker/Dockerfiles/apache
container_name: apache_mp
# command: bash -c "docker-php-ext-install pdo pdo_mysql && service apache2 restart"
depends_on:
- mysql
- redis
- certbot
ports:
# Exposing both http and https
- 80:80
- 443:443
environment:
- APACHE_DOCUMENT_ROOT=/var/www/html/public/
volumes:
- .:/home/medpets/WWW/
- ./docker/etc/apache2:/etc/apache2/
- ./docker/usr/local/etc/php/php.ini:/usr/local/etc/php/php.ini
- apache-log:/home/medpets/LOG/
- ./docker/etc/letsencrypt:/etc/letsencrypt/
- ./docker/etc/ssl:/etc/ssl/
certbot:
restart: "no"
image: certbot/certbot
container_name: certbot_mp
volumes:
- ./docker/etc/letsencrypt:/etc/letsencrypt/
volumes:
mysql-data:
redis-data:
apache-log:
The problem
Related
Here's what I've tried..
docker-compose.yml
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
image: digitalocean.com/php
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "8235:80"
- "455:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
- ./nginx/ssl:/etc/nginx/ssl
networks:
- app-network
# try this...
memcached:
container_name: memcached
image: memcached:latest
ports:
- "11212:11211"
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
Dockerfile
# ... omitted for brevity
# try this..
RUN apt-get update && apt-get install -y \
memcached
# now try this...
RUN docker-php-ext-install libz-dev libmemcached-dev
RUN docker-php-ext-install pecl install memcached
RUN docker-php-ext-install docker-php-ext-enable memcached
# and this...
RUN docker-php-ext-install build-essential libmemcached-dev libz-dev
RUN pecl install memcached-2.2.0
RUN echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini
The local site is up and serving files (Symfony) only I'm met with the memcached exception:
Any ideas?
Dropping this in my Dockerfile fixed it
RUN apt-get update && apt-get install -y libmemcached-dev \
&& pecl install memcached \
&& docker-php-ext-enable memcached
My db.docker file
FROM loongson.harbor.cn/larchloongsoncloud/loongnix-server:8.3
RUN yum install -y glibc-common
#RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV PGDATA /var/lib/postgresql/data
#COPY ./make/photon/db/postgresql.conf.sample /usr/share/postgresql/postgresql.conf.sample
RUN yum install -y shadow-utils gzip postgresql-server postgresql >> /dev/null \
&& groupmod --gid 9999 postgres \
&& usermod -g postgres --uid=9999 postgres \
&& mkdir -p /docker-entrypoint-initdb.d \
&& mkdir -p /run/postgresql \
&& chown -R postgres:postgres /run/postgresql \
&& chmod 2777 /run/postgresql \
# && mkdir -p /var/lib/postgresql/data && chown -R postgres:postgres /var/lib/postgresql && chmod -R 777 /var/lib/postgresql && ls -la /var/lib/ \
&& sed -i "s|#listen_addresses = 'localhost'.*|listen_addresses = '*'|g" /usr/share/pgsql/postgresql.conf.sample \
&& sed -i "s|#unix_socket_directories = '/tmp'.*|unix_socket_directories = '/run/postgresql'|g" /usr/share/pgsql/postgresql.conf.sample \
&& yum clean all
RUN mkdir -p /var/lib/postgresql/data
RUN chown -R postgres:postgres /var/lib/postgresql
RUN chmod -R 777 /var/lib/postgresql
RUN ls -la /var/lib/
RUN yum erase -y toybox && yum install -y util-linux net-tools
VOLUME /var/lib/postgresql/data
COPY ./make/photon/db/docker-entrypoint.sh /docker-entrypoint.sh
COPY ./make/photon/db/docker-healthcheck.sh /docker-healthcheck.sh
COPY ./make/photon/db/initial-notaryserver.sql /docker-entrypoint-initdb.d/
COPY ./make/photon/db/initial-notarysigner.sql /docker-entrypoint-initdb.d/
COPY ./make/photon/db/initial-registry.sql /docker-entrypoint-initdb.d/
RUN chown -R postgres:postgres /docker-entrypoint.sh /docker-healthcheck.sh /docker-entrypoint-initdb.d \
&& chmod u+x /docker-entrypoint.sh /docker-healthcheck.sh
#USER postgres:postgres
ENTRYPOINT ["/docker-entrypoint.sh"]
HEALTHCHECK CMD ["/docker-healthcheck.sh"]
EXPOSE 5432
USER postgres
My current docker-compose.yml file:
version: '2.3'
services:
log:
image: goharbor/harbor-log:dev
container_name: harbor-log
restart: always
dns_search: .
cap_drop:
- ALL
cap_add:
- CHOWN
- DAC_OVERRIDE
- SETGID
- SETUID
volumes:
- /var/log/harbor/:/var/log/docker/:z
- ./common/config/log/logrotate.conf:/etc/logrotate.d/logrotate.conf:z
- ./common/config/log/rsyslog_docker.conf:/etc/rsyslog.d/rsyslog_docker.conf:z
ports:
- 127.0.0.1:1514:10514
networks:
- harbor
registry:
image: goharbor/registry-photon:v2.7.1-patch-2819-2553-dev
container_name: registry
restart: always
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
volumes:
- /home/registry:/storage:z
- ./common/config/registry/:/etc/registry/:z
- type: bind
source: /home/secret/registry/root.crt
target: /etc/registry/root.crt
networks:
- harbor
dns_search: .
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "registry"
registryctl:
image: goharbor/harbor-registryctl:dev
container_name: registryctl
env_file:
- ./common/config/registryctl/env
restart: always
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
volumes:
- /home/registry:/storage:z
- ./common/config/registry/:/etc/registry/:z
- type: bind
source: ./common/config/registryctl/config.yml
target: /etc/registryctl/config.yml
networks:
- harbor
dns_search: .
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "registryctl"
**postgresql:
image: goharbor/harbor-db:dev
container_name: harbor-db
restart: always
cap_drop:
- ALL
cap_add:
- CHOWN
- DAC_OVERRIDE
- SETGID
- SETUID
volumes:
- /home/database:/var/lib/postgresql/data:z
networks:
harbor:
dns_search: .
env_file:
- ./common/config/db/env
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "postgresql"**
core:
image: goharbor/harbor-core:dev
container_name: harbor-core
env_file:
- ./common/config/core/env
restart: always
cap_drop:
- ALL
cap_add:
- SETGID
- SETUID
volumes:
- /home/ca_download/:/etc/core/ca/:z
- /home/psc/:/etc/core/token/:z
- /home/:/data/:z
- ./common/config/core/certificates/:/etc/core/certificates/:z
- type: bind
source: ./common/config/core/app.conf
target: /etc/core/app.conf
- type: bind
source: /home/secret/core/private_key.pem
target: /etc/core/private_key.pem
- type: bind
source: /home/secret/keys/secretkey
target: /etc/core/key
networks:
harbor:
dns_search: .
depends_on:
- log
- registry
- redis
- postgresql
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "core"
portal:
image: goharbor/harbor-portal:dev
container_name: harbor-portal
restart: always
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
- NET_BIND_SERVICE
networks:
- harbor
dns_search: .
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "portal"
jobservice:
image: goharbor/harbor-jobservice:dev
container_name: harbor-jobservice
env_file:
- ./common/config/jobservice/env
restart: always
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
volumes:
- /home/job_logs:/var/log/jobs:z
- type: bind
source: ./common/config/jobservice/config.yml
target: /etc/jobservice/config.yml
networks:
- harbor
dns_search: .
depends_on:
- core
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "jobservice"
redis:
image: goharbor/redis-photon:dev
container_name: redis
restart: always
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
volumes:
- /home/redis:/var/lib/redis
networks:
harbor:
dns_search: .
depends_on:
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "redis"
proxy:
image: goharbor/nginx-photon:dev
container_name: nginx
restart: always
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
- NET_BIND_SERVICE
volumes:
- ./common/config/nginx:/etc/nginx:z
networks:
- harbor
dns_search: .
ports:
- 80:8080
depends_on:
- registry
- core
- portal
- log
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "proxy"
networks:
harbor:
external: false
Why the initdb could not access ???
The first container is healthy (use docker run), but the second container is unhealthy (use docker-compose run ). The image is the same.
if you have already created this directory /home/database in your system, its file permission does not give permission to posgress. change the directory owner to 999.
I've got the following docker-compose
version: "3.9"
services:
php-apache:
image: php:7.3-apache
command:
- --default-authentication-plugin=mysql_native_password
- docker-php-ext-install
- mysqli pdo
- pdo_mysql
container_name: php-apache-container
depends_on:
- mysql
restart: always
volumes:
- ./api/:/var/www/html/
ports:
- 8010:80
links:
- mysql
mysql:
image: mysql:5.7
container_name: mysql-container
restart: always
environment:
TZ: "America/New_York"
MYSQL_ALLOW_EMPTY_PASSWORD: "no"
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: db_name
MYSQL_USER: db_user
MYSQL_PASSWORD: db_password
volumes:
- mysql-data:/var/lib/mysql
volumes:
mysql-data:
The php-apache-container keeps restarting.
But if I change this:
php-apache:
image: php:7.3-apache
command:
- --default-authentication-plugin=mysql_native_password
- docker-php-ext-install
- mysqli pdo
- pdo_mysql
into this:
php-apache:
build:
context: .
dockerfile: dockerfile
command: --default-authentication-plugin=mysql_native_password
And the dockerfile have the following content:
FROM php:7.3-apache
RUN docker-php-ext-install mysqli pdo pdo_mysql
It works, but I don't want to use a dockerfile, how can I make it work without using the dockerfile?
Thanks in advance!!!
I figured it out. I treated the command as a list but instead I added new lines with command and it works, looks like this:
php-apache:
image: php:7.3-apache
command: docker-php-ext-install
command: mysqli pdo
command: pdo_mysql
command: --default-authentication-plugin=mysql_native_password
container_name: php-apache-container
I'm trying to dockerize my Symfony project.
In this project, I have a folder under: public/fichiersflux/
"fichiersflux" is a folder with persistent data (img, pdf...)
Here is the docker-compose.yml:
version: '3.7'
services:
mariadb:
image: mariadb:10.4
restart: always
environment:
MYSQL_ROOT_PASSWORD: zfezZEFfz4e1589fze
MYSQL_DATABASE: 1c1t
MYSQL_USER: 1c1t
MYSQL_PASSWORD: fez45FZE1fez0fzefF!
ports:
- 3306:3306
php:
image: php:7.4
build:
context: .
dockerfile: docker/php/Dockerfile
restart: on-failure
user: 1000:1000
nginx:
image: nginx:1.17-alpine
restart: on-failure
volumes:
- './app/public/:/usr/src/app'
- './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro'
ports:
- 8080:80
depends_on:
- php
And my Dockerfile:
# ./docker/php/Dockerfile
FROM php:7.4-fpm
RUN docker-php-ext-install pdo_mysql
RUN pecl install apcu
RUN apt-get update && \
apt-get install -y \
zlib1g-dev
RUN apt-get install -y \
libzip-dev \
libicu-dev \
zip \
&& docker-php-ext-install zip
RUN docker-php-ext-enable apcu \
&& docker-php-ext-install intl
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /usr/src/app
COPY app/ /usr/src/app
RUN chown -R 1000:1000 /usr/src/app
RUN PATH=$PATH:/usr/src/apps/vendor/bin:bin
The problem is, when I build my docker containers, the folder /usr/src/app/ is apparently re-created.. and I loose all data inside public/fichiersflux
How can I persist public/fichiersflux folder ?
Best regards :)
You could just add volumes on php services, to mount your target folder.
version: '3.7'
services:
mariadb:
image: mariadb:10.4
restart: always
environment:
MYSQL_ROOT_PASSWORD: zfezZEFfz4e1589fze
MYSQL_DATABASE: 1c1t
MYSQL_USER: 1c1t
MYSQL_PASSWORD: fez45FZE1fez0fzefF!
ports:
- 3306:3306
php:
image: php:7.4
build:
context: .
dockerfile: docker/php/Dockerfile
volumes:
- '../app/public/fichiersflux:/usr/src/app/fichiersflux'
restart: on-failure
user: 1000:1000
nginx:
image: nginx:1.17-alpine
restart: on-failure
volumes:
- './app/public/:/usr/src/app'
- './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro'
ports:
- 8080:80
depends_on:
- php
I need to install laravel 5 app on Digital Ocean Server (under kubuntu 18) using Docker with VIRTUAL_HOST pointing to my my.freenom.com
host using proxy server (https://github.com/jwilder/nginx-proxy) and for this in my app I use configuraion
docker-compose.yml:
version: '3.1'
services:
web:
image: jwilder/nginx-proxy
build:
context: ./web
dockerfile: Dockerfile.yml
environment:
- APACHE_RUN_USER =#1000
- VIRTUAL_HOST =my.freenom.com
volumes:
- ./mysite.template:/etc/nginx/conf.d/mysite.template
ports:
- 8085:80
working_dir: ${APP_PTH_CONTAINER}
db:
image: mysql:5.5.62
restart: always
environment:
MYSQL_ROOT_PASSWORD: 1
volumes:
- ${DB_PATH_HOST}:/var/lib/mysql
adminer:
image: adminer
restart: always
ports:
- 8086:80
links:
- db
composer:
image: composer:1.6
volumes:
- ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
working_dir: ${APP_PTH_CONTAINER}
command: composer install --ignore-platform-reqs
and in web/Dockerfile.yml :
FROM nginx:1.10
RUN apt-get update -y && apt-get install -y libpng-dev \
nano libmcrypt-dev
RUN docker-php-ext-install \
pdo_mysql \
mcrypt \
&& a2enmod \
rewrite
but running command :
docker-compose up -d --build
I got error :
docker-php-ext-install: not found
Why error and which is correct way?
Thanks!