查看环境变量
echo $PATH
环境变量配置路径
-------------------全局变量(针对任何用户)--------------------
最先去读取 /etc/profile 文件

接着 读取 /etc/profile.d/ 目录下的文件
--------------------------------------------------------------------
然后读取用户家目录文件
-----------------------用户家目录文件-----------------------------
先读取 ~/.bash_profile

再读取 ~/.bashrc

再读取 /etc/bashrc (这个在etc下所以全局用户生效)
---------------------------------------------------------------------
使变量在子shell中生效
export 变量名
自定义别名
alias dd="df -h" ##仅当前生效
vim /etc/bashrc #所有用户生效

vim ~/.bash_profile #仅当前用户神效
--------------------Linux(容器)-------------------------


yum install docker -y #安装docker
(桥接模式)
docker是c/s架构
docker info #查看docker信息
docker images (查看docker的镜像)
docker search centos (查询仓库镜像(官方的镜像库))

docker pull centos (会自动去拉官方镜像)
或者自己导入仓库
docker import -< 镜像文件

查看镜像库
docker images

service docker start 或者 systemctl start docker 运行docker
docker run --name 名称 -i -t e934aafc2206(或者名字centos) /bin/bash (登陆后执行的命令)
ctrl+d 退出容器且关闭.
docker ps -a 列出所有容器(不加 -a 就只显示运行的程序)

docker attach ce81947c698d 进入容器
#ifconfig 与 ip a 的命令都没有 只有 cat /etc/hosts 查看ip

本机可ping通
容器里的进程机器里可看

修改后保存配置
docker commit -m "随便写个标记" 老名字 新名字
---------------------搭建流程---------------------------
yum install docker -y ##安装docker
service docker start ##开启docker服务
docker import -< 镜像文件 ##导入自己的镜像
docker images ##查看镜像库
docker ps ##查看当前运行容器 -l :查看最新创建的容器 -n=x 列出最后创建的x个容器 -a 所用容器
docker run --name=docker_centos(名称) -i -t e934aafc2206(或者名字centos) /bin/bash
##创建一个新的容器并运行一个命令并且进入交互模式
输入exit或者Ctrl+C 退出container,仍然在后台运行
docker attach docker_centos 或 docker exec -it docker_centos(名称) /bin/sh (进入交互模式)
docker start docker_centos(id或者容器名) ##启动容器
docker stop docker_centos ##关闭容器
docker rm [NAME]/[CONTAINER ID] :
docker stop $(docker ps -q) #停止所有容器
docker rm $(docker ps -q) #移除所有容器
docker commit 1b895643e95a(容器ID) Mar_image(镜像名字) #保存容器为镜像
docker 镜像库(输入名字查找镜像得使用方法) https://hub.docker.com
##在docker里安装某个服务想启动出现这个错误 Failed to get D-Bus connection: Operation not permitted
## 解决办法一:就是在docker run 的时候运行/usr/sbin/init #在redhat上遇到的
docker run -tid --name centos e934aafc2206 /usr/sbin/init ##运行docker需要执行这个命令
##解决办法二:在centos7上遇到的
创建容器:
# docker run -d --name centos7 --privileged=true centos:7 /usr/sbin/init
进入容器:
# docker exec -it centos7 /bin/bash
这样可以使用systemctl启动服务了。
-------------------------selinux的BUG未解决,只能关了selinux-------------
SELinux is preventing /usr/lib/systemd/systemd from write access on the directory system.slice. For complete SELinux messages run: sealert -l 6a33c3ed-2203-4a42-a2e6-71db815b9e45
Jun 5 08:17:52 tc python: SELinux is preventing /usr/lib/systemd/systemd from write access on the directory system.slice.#012#012***** Plugin catchall_boolean (89.3 confidence) suggests ******************#012#012If you want to allow container to manage cgroup#012Then you must tell SELinux about this by enabling the 'container_manage_cgroup' boolean.#012#012Do#012setsebool -P container_manage_cgroup 1#012#012***** Plugin catchall (11.6 confidence) suggests **************************#012#012If you believe that systemd should be allowed write access on the system.slice directory by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'systemd' --raw | audit2allow -M my-systemd#012# semodule -i my-systemd.pp#012
本文详细介绍Docker的安装、启动及基本操作,包括容器的创建、启动、停止等,并提供了常见问题解决方案。


被折叠的 条评论
为什么被折叠?



