docker 宿主机与容器 container 需要进行一些文件同步操作,需要获取 container 容器的 ip 地址,应该怎么获得呢?
走同样的路,发现不同的人生
docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER_ID
The IP of the container will change every time it is started, so knowing the IP of the container is meaningless. For file synchronization operations, why not mount it to the host through -v?
docker exec CID ifconfig If the container has ifconfig
Very simple docker inspect container ID | grep IP
docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER_ID
The IP of the container will change every time it is started, so knowing the IP of the container is meaningless.
For file synchronization operations, why not mount it to the host through -v?
docker exec CID ifconfig
If the container has ifconfig
Very simple docker inspect container ID | grep IP