If I understand well, for development, you want localhost to be resolved in a specific container, including when called from another container.
Host redirection
hosts, , , , , , ... .
.
Docker
Docker Toolbox Virtual Box, , localhost . , , Virtualbox. Wordpress :
docker run -p 80:80 --name website -d wordpress- → ( ) → → 1 → → 8080 80
Wordpress http://localhost:8080. , MacOS - ( 1024).
, script:
VBoxManage modifyvm "default" --natpf1 "app,tcp,,8080,,80"
Windows/Docker Mac
Docker for Windows/Docker for Mac ( Linux), Docker Toolbox, , -p, , ( VM Linux):
docker run -p 5432:5432 --name myapp -d myimage myapp localhost:5432.
socat ( iptables)
socat , :
socat TCP-LISTEN:5432,fork,reuseaddr,user=node,group=node,mode=777 TCP:172.19.0.1:5432 &
( 172.19.0.1 - IP- )
-
hosts , , :
docker run ubuntu cat /etc/hosts
hosts --add-host:
docker run --add-host domain:1.2.3.4 --add-host domain2:5.6.7.8 ubuntu cat /etc/hosts
localhost, localhost. , ( ), - --network=host, :
docker run --network=host ubuntu
, , .
, - , localhost.
docker run -d --name mariadb -e MYSQL_ROOT_PASSWORD=password mariadb
docker run -d --name="wordpress" -p 8080:80 -e WORDPRESS_DB_PASSWORD=password --link mariadb:mysql wordpress
Wordpress mysql hosts, IP- mariadb. , bash Wordpress .
docker exec -ti wordpress bash