美文网首页
docker起ubuntu当虚拟机用

docker起ubuntu当虚拟机用

作者: 王大吉 | 来源:发表于2019-11-16 00:30 被阅读0次

    设定在同一个网络

    因为直接起的dockerIP是不固定的,重启以后会按重启的顺序分配IP,既然我们要当虚拟机用,就得给个固定的IP
    docker network ls发现,docker自带三种类型的网络,但其实都不满足,所以我们需要自己定一个网络类型

    NETWORK ID     NAME        DRIVER       SCOPE
    9781b1f585ae    bridge       bridge       local
    1252da701e55    host        host        local
    237ea3d5cfbf    none        null        local
    
    docker network create --subnet=10.10.10.0/24 network10
    docker run -itd --name ubuntu_one --network network10 --ip 10.10.10.11 ubuntu:18.04 /bin/bash
    

    酱紫就好咯
    https://www.cnblogs.com/xuezhigu/p/8257129.html

    装基本的包

    1. 换apt源
    eb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
    

    覆盖到 /etc/apt/source_list里

    > apt-get update
    > apt-get install vim
    > apt-get install net-tools
    > apt-get install iputils-ping
    > apt-get install openssh-server
    

    给敲passwd设置一个密码

    > passwd
    

    修改 /etc/ssh/sshd_config 里的 PermitRootLogin 为 yes
    /etc/init.d/ssh restart重启ssh就可以了

    相关文章

      网友评论

          本文标题:docker起ubuntu当虚拟机用

          本文链接:https://www.haomeiwen.com/subject/hiueictx.html