extra_hosts 修改hosts文件
extra_hosts:
- somehost:162.242.195.82
- otherhost:50.31.209.229
配置容器固定IP
docker-compose配置固定IP各种问题
version: '3.5'
services:
hadoop1:
image: hadoop:1.3
container_name: hadoop1
command: bash -c "/usr/sbin/sshd && /bin/bash"
tty: true
networks:
mynetwork:
# 宿主机会自动配置网关IP:172.20.1.1
ipv4_address: 172.20.1.2
networks:
mynetwork:
driver: bridge
ipam:
# 这里不用配置driver
# driver: default
config:
- subnet: "172.20.1.0/24"
启动后容器不退出, 交互命令后台运行
version: "3"
services:
app:
image: app:1.2.3
stdin_open: true # docker run -i
tty: true # docker run -t
Was this article helpful to you?
Yes
No