docker

修改ip

vi /etc/netplan/50-cloud-init.yaml

    network:
        ethernets:
            ens33:
              addresses: [192.168.141.130/24]
              gateway4: 192.168.141.2
              nameservers:
                addresses: [192.168.141.2]
        version: 2

修改主机名

hostnamectl set-hostname 你的名字

配置hosts

cat >> /etc/hosts << EOF
你的ip 你的主机名
EOF

netplan apply命令让配置生效

version: '3.1'
services:
  db:
    image: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    command:
      --default-authentication-plugin=mysql_native_password
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --explicit_defaults_for_timestamp=true
      --lower_case_table_names=1
    ports:
      - 3306:3306
    volumes:
      - ./data:/var/lib/mysql

  #mysql web client(php)
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

你可能感兴趣的:(docker)