简体   繁体   中英

URL keeps changing when running a docker container on localhost in a --network

I am using this guide: https://github.com/osixia/docker-phpLDAPadmin

to start two containers: OpenLDAP and phpldapadmin. I start them with:

docker run --network=$NETWORK_NAME --name $LDAP_CONTAINER_NAME --detach --hostname $LDAP_CONTAINER_NAME -p 389:389 -p 689:689 $LDAP_IMAGE_NAME

docker run --network=$NETWORK_NAME --name $PHP_LDAP_CONTAINER_NAME --detach --hostname $PHP_LDAP_CONTAINER_NAME --env PHPLDAPADMIN_LDAP_HOSTS=$LDAP_CONTAINER_NAME $PHP_LDAP_IMAGE_NAME

Now the $PHP_LDAP_CONTAINER_NAME I access from my browser on https://172.18.0.4/ but yesterday when I ran it was on https://172.18.0.3/ . Is there anyway to keep it on the same location and use something like: http://localhost:xxxx where xxxx is a static port?

Yes. Publish the 443 port like this:

docker run --network=$NETWORK_NAME --name $PHP_LDAP_CONTAINER_NAME --detach --hostname $PHP_LDAP_CONTAINER_NAME --env PHPLDAPADMIN_LDAP_HOSTS=$LDAP_CONTAINER_NAME -p 443:443 $PHP_LDAP_IMAGE_NAME

Just add the -p 443:443 to your last command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM