文章正文

docker入门命令整理

加入时间:2018/1/18 11:48:00

docker search ubuntu
这是从docker提供的资源库搜索ubuntu资源
docker  pull ubuntu:latest
这是下载最新版本的检索到的ubuntu资源
docker exec -ti test bash
这个是 进入  一个容器的 基本命令
test 是 容器的名次或 id
用 前面的 id 或 后面的名称都可以。 
id 只需要输入 前 4位
docker ps 是查看正在运行的 容器
docker ps -a 是查看所有容器。
docker image list 是查看所有镜像
docker rm xxxx  是删除一个容器

docker images
查看下载的镜像
docker start xxxx 运行一个容器
docker stop xxxxx 关闭一个容器

docker run --name ubuntu001 ubuntu tail -f /etc/hosts
这个是ubuntu 这种需要在run的时候运行一个内部程序,保证程序不关闭

需要查看docker 的详细用法
查看如果 渗透 数据到宿主机

懒得转了,具体看这个文章吧,2018.11.26才看到的,放这备注

https://blog.csdn.net/S_gy_Zetrov/article/details/78161154

 

Docker容器里的centos、unbuntu无法使用 systemctl 命令的解决方案

来源:https://blog.csdn.net/u013829518/article/details/99681154

据说在 Linux Docker中无法使用 systemd(systemctl) 相关命令的原因是 1号进程不是 init ,而是其他例如 /bin/bash ,所以导致缺少相关文件无法运行。(System has not been booted with systemd as init system (PID 1). Can't operat)

解决方案:/sbin/init

例如:Ubuntu 18.04 ,

docker run -tid --name test --privileged=true centos /sbin/init
docker exec -it test /bin/bash

PS:--privileged=true一定要加上的。

 

Docker 修改镜像为阿里镜像

https://www.cnblogs.com/yanguhung/p/10789129.html

 

1、首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo

[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

 

2、查看CentOS系统版本

[root@localhost ~]lsb_release -a

 

3、下载ailiyun的yum源配置文件到/etc/yum.repos.d/


CentOS8

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

CentOS7

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

CentOS6

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS5

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo



4、运行yum makecache生成缓存

[root@localhost ~]# yum makecache

 

5、这时候再更新系统就会看到以下mirrors.aliyun.com信息

[root@localhost ~]# yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com

字体大小[ ]

版权所有:有信心——uxinxin 我的个人网站欢迎常来!手机版(新站开启,请多多关照) 豫ICP备12017930号-1
 豫公网安备 41910102000493号