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

Swarm scheduling not working as expected using filters in compose file
issues in buiding Slate with Docker
Invalid type error in Docker Compose
Django cookiecutter with Docker add pip package
Docker Compose + Swarm + Machine Networking issue
docker-compose build image parameters --force-rm --pull
linking 2 containers through docker compose
Files created by manage.py commands not chown'd from root user
Is it possible to create an intermediate image within docker-compose?
docker-compose service listen on specified interface
Does Docker-Compose allow overwriting of ports when using extends?
Jhipster Docker-compose conflict
Build multiple images with Docker Compose?
JHipster Cassandra Docker Build
Defining project name inside docker-compose configuration
Docker-compose named mounted volume

Categories

HOME
redux
weblogic
abc
postsharp
redhawksdr
hiveql
glympse
liquidsoap
normals
google-app-maker
oms
google-search-appliance
facebook-sharer
dynamics-crm-2011
expo
camunda
cakephp-2.0
derby
github-flavored-markdown
background-image
google-street-view
datazen-server
mongoose-im
ballerinalang
workflow-foundation
marionette
units-of-measurement
dynamics-ax-2012-r3
pushpad
ocl
edsdk
textview
ibm-bpm
keil
ports
strategy-pattern
mapquest
jquery-inputmask
gem-fury
ape-phylo
autodesk-data-management
flume-ng
paperclip
django-cors-headers
niagara-ax
text-formatting
riemann
photoshop-script
richtext
overhead
sharing
fileopendialog
system-integration
razorengine
ooad
sqldataadapter
encode
dynamics-nav
php-gd
self-join
data-representation
autopep8
douglas-peucker
kss
frisby.js
conditional-comments
xtify
google-mirror-api
google-voice
xcode5.1
dylan
pechkin
nokogiri
usersettings
wordbreaker
database-restore
django-tinymce
qt5.1
m3u
xcode4.6.3
django-admin-tools
sqlbuddy
unordered-set
automapper-2
httppostedfilebase
jqtransform
nbehave
hs-err
large-data-volumes
glassfish-embedded
opengl-to-opengles
asp.net-1.1
paperless

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