not in one docker container but yes in n docker containers.
While you could - theoretically - assemble your whole dev environment inside one single container, docker was not meant to do this.
Instead you should deploy each service into separate containers, using docker compose, managing your whole infrastructure in one single file, where each service will have its own logfile, userspace, networking, etc.
Let me give you an example, this is a draft of my docker-compose.yml
version: '2'
services:
myproxy:
build: myproxy
container_name: ppproxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
default:
aliases:
- www.domain1.it
- www.domain2.it
- www.domain4.it
mydb1:
build: mydb
environment:
DB_USER: sdffdssdf
DB_PASSWORD: fdsfsdsdf
DB_NAME: dbanme1
DB_ENCODING: UTF-8
VIRTUAL_HOST: myhost1.net.lan
VIRTUAL_PORT: 5432
mydb2:
build: mydb
environment:
DB_USER: ssdfsdfs
DB_PASSWORD: sffdssd
DB_NAME: dbanme2
DB_ENCODING: UTF-8
VIRTUAL_HOST: myhost2.net.lan
VIRTUAL_PORT: 5432
www:
image: myimages/oldservice:v1.1
container_name: www
command: /bin/bash /root/launch
environment:
VIRTUAL_HOST: www.domain1.it
VIRTUAL_PORT: 80
ports:
- 80
depends_on:
- mydb1
- mydb1
- myws
myws:
build: myjettycontainer
environment:
HTTPS_METHOD: noredirect
VIRTUAL_HOST: www.domain2.it
VIRTUAL_PORT: 8080
ports:
- 8080
depends_on:
- mydb1
- mydb2
- myproxy
- mypostfix
mypostfix:
image: catatnight/postfix
container_name: mailer
environment:
maildomain: domain1.it
smtp_user: mymail:sfsfdfds
ports:
- 25
There is an nginx proxy (myproxy), two similar postgres databases (mydb1 and 2), an old java web application server (www), a java jetty container that provides a rest web service and finally a very simple SMTP postfix container.
Everything starts up - usually :) - with docker-compose up
, either on my dev machine or in production; log files are aggregated into one easy to read file and it is possible to replicate locally almost every functionality with the guarantee that, if it works on my laptop it will work.