docker-compose


Using custom hostnames for docker local development containers


I am playing around with Docker for Windows (just starting out) and have this simple docker-compose.yml which works great:
version: '2.1'
services:
db:
image: mysql:latest
container_name: wordpresslab_db
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_USER: wordpress
MYSQL_DATABASE: wordpress
MYSQL_PASSWORD: wordpress
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: wordpresslab_phpmyadmin
volumes:
- /sessions
ports:
- "8090:80"
depends_on:
- db
wordpress:
image: wordpress:latest
container_name: wordpresslab_wordpress
volumes:
- ./:/var/www/html
ports:
- "8080:80"
depends_on:
- db
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
Once I run docker-compose up -d it creates the containers for database, phpmyadmin and wordpress website and are accessible and working OK.
My question is, how could I setup "project.dev" instead of a "localhost:8080" to access wordpress site and "phpmyadmin.dev" instead of a "localhost:8090" to access phpmyadmin? What other tools do I need? Note that I am using Windows 10 as host.
I think you want to use port mapping as described in the networking doc.
https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-networking#network-creation
There's also a Docker doc on ports in compose files.
https://docs.docker.com/compose/compose-file/#long-syntax
Please note that there are differences in syntax depending on which version of docker compose you are using. You can check your version by running this command in a command prompt:
docker-compose --version
Let me know if you're still running into trouble!

Related Links

compose extend file results in a validation error
hubot rocketchat adapter does not work
Docker compose lables constraint:node not work
is it possible to generate a random mysql password with dockercompose
Networking Docker Compose
How to change the config file for Riak TS when using Docker
Django Docker-compose machine does not start web server
How should docker-compose jobs discover etcd?
docker compose adding nodes dynamically to nginx frontend
Docker Swarm - dependencies definition
docker-compose volume not mounted
Exposing sentry service in docker-compose file
Yesod and docker-compose logs in development mode
Docker compose to always deploy using latest image
JHipster - Doubts in the development using Microservices Architecture
Gogs + Drone getsockopt: connection refused

Categories

HOME
alasql
mobile
domain-driven-design
data-modeling
arguments
query-string
overrides
xss
handlebars.js
google-api-oauth
dynamics-crm-2011
xmlhttprequest
watson-dialog
react-select
box2d
ringcentral
vivado-hls
hololens
gnu-screen
ps
apdu
akavache
windows-mobile
adobe-captivate
smart-device
multiple-inheritance
typeorm
meteor-accounts
pypy
ipython-parallel
jbossfuse
folder
mobile-development
undo
akamai
exacttarget
wordpress-rest-api
choco
geocomplete
java-5
directadmin
quartz
intervention
cakephp-3.2
inner-join
serialversionuid
photoshop-script
totalview
jtextarea
reloaddata
dynatable
nls
directinput
easy-thumbnails
android-music-player
dimensionality-reduction
class-design
xcode7.1
foreground
magick.net
hoare-logic
normalisation
bytearray
periodic-processing
fadein
computability
producer-consumer
traminer
vanilla-forums
winforms-interop
borland-c++
mind-manager
zoneminder
nsnotificationcenter
azure-worker-roles
jsmpp
flask-mongoengine
xcode6.1-gm-seed
tlbimp
infinity.js
wordbreaker
gmail-imap
setcookie
algol
ncml
volatility
certificate-revocation
pinchzoom
fileoutputstream
umfpack
qvariant
cryptolicensing
marathontesting
mass-emails
s60
oaw
xslt-grouping
coderush-xpress
time-management
scala-designer

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App