Docker容器中运行Ubuntu系统
1、安装Ubuntu系统命令:docker pull ubuntu这是一个极度精简的系统,连最基本的wget命令都没有;所以先要apt-get update升级系统和安装apt-get install wget命令;
2、运行进入Ubuntu系统命令:docker run -ti ubuntu bash进入ubuntu容器:docker exec -it ubuntu bash
3、正确退出系统方式:先按,ctrl+p再按,ctrl+q绝对不能使用exit或者ctrl+d来退出,这样整个系统就退出了!!!
4、共享宿主机目录到Ubuntu系统中:docker run -it -v /AAA:/BBB ubuntu bash
这样宿主机根目录中的AAA文件夹就映射到了容器Ubuntu中去了,两者之间能够共享;
5、登陆docker中的ubuntu镜像系统:docker run -ti ubuntu /bin/bash
#6866 是 IMAGE ID 前四位数字-能区分出是哪个image即可
6、退出后 再进入ubuntu1、首先用docker ps -a 查找到该CONTAINER ID对应编号(比如:0a3309a3b29e)2、进入该系统 (此时没反应,ctrl+c就进入到ubuntu系统中去了)docker attach 0a3309a3b29e
PS:我运行的命令docker run -it -v /download:/download -p 53:53 ubuntu bash
附加常用命令:一、查看ubuntu版本:cat /etc/issue
二、修改ubuntu镜像源为ubuntu:1、备份cp /etc/apt/sources.list /etc/apt/sources.list.backup
2、清空内容加入以下内容 vi /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
3、更新生效:apt-get update
三、安装开启ssh运行用户远程登录1、安装sshd命令:apt-get install openssh-server openssh-client
2、编辑/etc/ssh/sshd_config ,注释掉:PermitRootLogin without-password,增加PermitRootLogin yes
3、启动命令service ssh start
页:
[1]