First of all, thank you for your attention to my code. I have a hard time translating Docker documentation. I tried to remove the code from the Dockerfile and actually the volume still generates. I still don’t understand volumes: if I try to remove “volumes” from docker-compose.yaml, I always find an unnamed volume after typing “docker volume ls” and I don’t understand where it is generated. Another very serious problem I have is related to the management of volumes. I can’t move the volumes next to the docker-compose.yaml file. Regarding postgresql and mysql it is not a problem because with pgadmin and phpmyadmin I can recover the data. If the webapp saves images on the server I don’t know how to retrieve them. If I understand correctly, I don’t have this problem with php because in the folder “ServerDocker02/php/serverfile/” I find the images inserted by the client. I can also edit index.php and see the changes in the browser. With Tomcat I have a poke and this is a very serious problem.
Another mistake that I fear I have made regarding the version of the starting images. Regarding Tomcat / Java I’m sure I’m not wrong. My WebApps on Tomcat 10 not working, I can only use the penultimate version (Tomcat 9.x). Regarding the other images I chose at random (the first name given to me by Google). As for PostgreSQL, PostGIS, MySQL, pdAdmin, phpMyAdmin I need the latest versions.
As for Apache / PHP I would like to put the most updated version because I will write modern apps and I will install WordPress which is a very up-to-date CMS.
I am also in doubt whether to use nginx or apache. The ultimate goal is to have a server that starts tomcat or apache depending on the url. Example:
https://localhost:80/appjava > tomcat needs to start
https://localhost:80/wordpress > apache needs to start
However, I proceed in small steps because for me it is already too complex for my basic skills.
Below you can find the http version that works perfectly. When I add https the php service stops working. This fact sends my brain haywire and demoralizes me a lot.
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/https/000-default.conf
<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/localhost-rsa-cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/localhost-rsa-key.pem
ServerAdmin admin@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/https/localhost-rsa-cert.pem
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/https/localhost-rsa-key.pem
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/https/server.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the
AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation which always uses
OpenSSL for TLS.
Either JSSE or OpenSSL style configuration may be used. OpenSSL style
configuration is used below.
-->
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="ssl/localhost-rsa-key.pem"
certificateFile="ssl/localhost-rsa-cert.pem"
certificateKeyPassword="changeit"
type="RSA" />
</SSLHostConfig>
</Connector>
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/mysql/Dockerfile
FROM mysql
LABEL Author="Nome Cognome"
EXPOSE 3306
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/pgadmin/Dockerfile
FROM dpage/pgadmin4:latest
LABEL Author="Nome Cognome"
EXPOSE 80
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/pgadmin/servers.json
{
"Servers": {
"1": {
"Group": "Server PostgreSQL e PostGIS",
"Name": "Server 1",
"Port": 5432,
"Username": "eb",
"Host": "postgresql-postgis",
"SSLMode": "prefer",
"MaintenanceDB": "postgres"
}
}
}
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/php/Dockerfile
FROM php:8.0-apache
LABEL Author="Nome Cognome"
EXPOSE 80
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN apt-get update && apt-get upgrade -y
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/phpmyadmin/Dockerfile
FROM phpmyadmin/phpmyadmin
LABEL Author="Nome Cognome"
EXPOSE 80
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/postgresql-postgis/Dockerfile
FROM kartoza/postgis:13.0
LABEL Author="Nome Cognome"
EXPOSE 5432
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/tomcat/Dockerfile
FROM tomcat:9.0.63-jdk11
LABEL Author="Nome Cognome"
EXPOSE 8080
EXPOSE 8443
COPY ./serverfile/*.war /usr/local/tomcat/webapps/
CMD ["catalina.sh", "run"]
/home/gi/Dropbox/SERVER/DOCKER-LINUX/ServerDocker02/docker-compose.yaml
version: '3.8'
services:
postgresql-postgis:
build: ./postgresql-postgis
image: image-postgresql-postgis-eb:v.1.0
container_name: container-postgresql-postgis-eb
ports:
- 6001:5432
volumes:
- data-postgresql:/var/lib/postgresql
environment:
POSTGRES_USER: "eb"
POSTGRES_PASS: "password"
POSTGRES_DBNAME: "gis"
ALLOW_IP_RANGE: "0.0.0.0/0"
restart: always
networks:
- eb
pgadmin:
build: ./pgadmin
image: image-pgadmin-eb:v.1.0
container_name: container-pgadmin-eb
ports:
- 6002:80
volumes:
- ./pgadmin/servers.json:/pgadmin4/servers.json
environment:
PGADMIN_DEFAULT_EMAIL: admin@gmail.com
PGADMIN_DEFAULT_PASSWORD: password
depends_on:
- postgresql-postgis
restart: always
networks:
- eb
tomcat:
build: ./tomcat
image: image-tomcat-eb:v.1.0
container_name: container-tomcat-eb
ports:
- 6003:8080
- 7003:8443
volumes:
- ./https/localhost-rsa-cert.pem:/usr/local/tomcat/ssl/localhost-rsa-cert.pem
- ./https/localhost-rsa-key.pem:/usr/local/tomcat/ssl/localhost-rsa-key.pem
- ./https/server.xml:/usr/local/tomcat/conf/server.xml
depends_on:
- postgresql-postgis
- pgadmin
restart: on-failure
networks:
- eb
mysql:
build: ./mysql
image: image-mysql-eb:v.1.0
container_name: container-mysql-eb
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: gis
MYSQL_USER: eb
MYSQL_PASSWORD: password
ports:
- 6004:3306
volumes:
- data-mysql:/var/lib/mysql
networks:
- eb
phpmyadmin:
build: ./phpmyadmin
image: image-phpmyadmin-eb:v.1.0
container_name: container-phpmyadmin-eb
ports:
- 6005:80
restart: always
environment:
PMA_HOST: mysql
depends_on:
- mysql
networks:
- eb
php:
build: ./php
image: image-php-eb:v.1.0
container_name: container-php-eb
ports:
- 6006:80
volumes:
- ./php/serverfile:/var/www/html
depends_on:
- mysql
- phpmyadmin
networks:
- eb
volumes:
data-postgresql:
data-mysql:
networks:
eb: