I try to switch all my app to docker.
The configuration:
I used nginx as server. With docker i will use it as proxy:
# nginx -v
nginx version: nginx/1.4.6 (Ubuntu)
Docker version:
# docker version
Client:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 5604cbe
Built: Tue Apr 26 23:30:23 2016
OS/Arch: linux/amd64
Server:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 5604cbe
Built: Tue Apr 26 23:30:23 2016
OS/Arch: linux/amd64
# docker-compose -version
docker-compose version 1.7.1, build 0a9ab35
The install:
To install piwik, i use the file suggest here: indiehosters/piwik
But i made some change because i would like: - i would like to use a custom db so i configure an additional user and a password. - i would like to use different containers of mysql by app so i change db to piwik_db (i am not sure it's a good practice) - i would like to get a phpmyadmin access but i don't understand to make it work with the point 2. So i remove the config part.
So my docker compose fil looks like this:
piwik_db:
image: mysql
volumes:
- ./mysql/runtime:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: P@ssR00t
MYSQL_DATABASE: analytics
MYSQL_USER: admin
MYSQL_PASSWORD: P@ssUser
app:
image: piwik
links:
- piwik_db:mysql
volumes:
- ./config:/var/www/html/config
- ./ssmtp.conf:/etc/ssmtp/ssmtp.conf
- ./revaliases:/etc/ssmtp/revaliases
web:
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./etc/letsencrypt:/etc/letsencrypt
links:
- app
volumes_from:
- app
ports:
- "8000:443"
cron:
image: piwik
links:
- piwik_db:mysql
volumes_from:
- app
entrypoint: |
bash -c 'bash -s <<EOF
trap "break;exit" SIGHUP SIGINT SIGTERM
while /bin/true; do
su -s "/bin/bash" -c "/usr/local/bin/php /var/www/html/console core:archive" www-data
sleep 3600
done
EOF'
The result:
When i run docker-compose up
, it finish with an error:
ERROR: for web rpc error: code = 2 desc = "oci runtime error: could not synchronise with container process: not a directory"
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "compose/cli/main.py", line 63, in main
AttributeError: 'ProjectError' object has no attribute 'msg'
docker-compose returned -1
When i test which containers was installed, i get
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0388c2a89d3 piwik "bash -c 'bash -s <<E" About a minute ago Up 59 seconds 9000/tcp htdocs_cron_1
ef5d6c8c6e74 mysql "docker-entrypoint.sh" About a minute ago Up About a minute 3306/tcp htdocs_piwik_db_1
Why i get the error? How to achieve the install? How to make the app always running?
Thank you in advance for any help.
Ps: I still use my nginx config in site-available:
server {
listen 80;
listen [::]:80;
server_name piwik.domain.com;
# Redirige le HTTP vers le HTTPS #
return 301 https://$server_name$request_uri;
}
server {
##
# config SSL
##
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/piwik.domain.com.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/piwik.domain.com.com/privkey.pem;
keepalive_timeout 70;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
fastcgi_param HTTPS on;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000";
server_name piwik.domain.com.com;
server_name_in_redirect off;
root /usr/share/nginx/html/piwik.domain.com.com/htdocs;
index index.php index.html index.htm;
# Logs
access_log /var/log/analytics.access_log;
error_log /var/log/analytics.error_log;
# Default location settings
location / {
try_files $uri $uri/ /index.php?$args;
charset utf-8;
client_max_body_size 20M;
}
# Images and static content is treated different
location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|html|woff|woff2|ttf|svg|eot|otf)$ {
add_header Access-Control-Allow-Origin *;
expires 360d;
access_log off;
add_header Cache-Control "public";
}
# Deny access to .htaccess files, if Apache's document root
location ~ /\.ht {
deny all;
}
location ~ /(libraries|setup/frames|setup/libs) {
deny all;
return 404;
}
# Pass the PHP scripts to FastCGI server
location ~* \.php$ {
# Prevent Zero-day exploit
try_files $uri =404;
#
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
# Redirect server error pages to the static page
error_page 403 /403.html;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
# Exclude from the logs to avoid bloating when it's not available
include drop.conf;
}