I am using Docker for Windows and would like to know if each container could have its own IP address that I could map on the host file and assign a hostname.
Currently, when I input http://localhost:8081/ on my browser, it is showing my Laravel application (which is fine) However, rather than having that URL, I wanted it to be something like: http://myapp.local/ to give it a more distinctive name.
Since I will be running multiple containers, most likely I will run it using multiple ports like so:
http://localhost:8082/
http://localhost:8083/
and so on..
Which should map in such way:
http://localhost:8082 = http://anotherapp.local
http://localhost:8083 = http://andanotherapp.local
Here's my docker-compose.yml
version: '3.7'
services:
app:
build:
context: .
dockerfile: .docker/Dockerfile
image: 'laravelapp'
ports:
- 8081:80
volumes:
- ./:/var/www/html
container_name: laravelapp
db:
image: mysql:5.7
restart: always
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: 'laraapp_db'
MYSQL_USER: "homestead"
MYSQL_PASSWORD: "secret"
MYSQL_DATABASE: "laravelapp_db"
MYSQL_ROOT_PASSWORD: "secret"
volumes:
- ./.database:/var/lib/mysql
container_name: laraveldb