1.常用命令
2.获取container ip地址
3.安装ssh
4.网络
5.向docker拷贝文件5.1.
docker cp hadoop/ 16859e097ec7:/tmp/hadoop
6.docker创建网络失败需检查iptables中是否有docker chain,iptables重启会导致docker chain丢失
6.1.[错误信息]
sudo docker network create --subnet=172.18.0.0/16 dockernetwork
报Error response from daemon: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-e9de5855aefb -j RETURN: iptables: No chain/target/match by that name. (exit status 1))
6.2.相关命令6.2.1.
sudo iptables -L -n -t nat | grep DOCKER
6.2.2.sudo systemctl restart docker
6.2.3.sudo systemctl iptables save
6.3.参考
6.3.1.创建网络
6.3.2.设定端口映射:sudo docker run -it -p 9870:9870 -p 8088:8088 --name hadoop_172.18.0.2 --network=dockernetwork --ip 172.18.0.2 peterwangsl:hadoop3.0.0 /bin/bash
6.3.3. 挂载文件夹:sudo docker run -it -p 1521:1521 --name zzb_oracle_172.18.0.4 --network=dockernetwork --ip 172.18.0.4 -v /software/oracle/data/zzb:/home/oracle/app/oracle/oradata/ registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g:latest /bin/bash
7.我的仓库
8.1
xfs_growfs /dev/mapper/docker-*-$container_id
9.docker运行springboot jar
docker run -d \
--restart=always \
-v /home/data/uploadPath:/home/data/uploadPath \
-v /home/webapp:/home/webapp \
-p 48080:80 \
--name sc-admin \
-w /home/webapp \
-e TZ="Asia/Shanghai" \
-e "SPRING_PROFILES_ACTIVE=court-dev" \
-e "SERVER.PORT=80" \
-e "JAVA_OPTS=-Dname=sc-admin.jar -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" \
dockette/jdk8:latest /usr/bin/java -jar \
/home/webapp/sc-admin.jar
10、通过代理安装docker-ce
1.参照1
2.centos阿里源问题解决
3.containerd.io-1.2软件包与预期下载的不符 ,可以安装旧版dockeryum -y install docker-ce-18.06.0.ce-3.el7
4.更改安装目录、镜像
/etc/docker/daemon.json
{
"registry-mirrors": ["http://aad0405c.m.daocloud.io","http://hub-mirror.c.163.com"],
"graph": "/data/software/docker"
}
5.配置代理
1、使用docker pull hub.c.163.com/library/nginx
6.docker镜像
7.docker安装gitlab,更改端口后运行
docker exec -ti gitlab gitlab-ctl restart
1.备份gitlab,配置文件
/etc/gitlab/gitlab.rb
的gitlab_rails['backup_path']
,备份命令/bin/docker exec -t gitlab gitlab-rake gitlab:backup:create
2.备份docker
docker commit -a ‘汪敏’ -m ‘gitlab备份’ 9e7849fa0dbe wangmin/gitlab:3.0
-a 作者
-m 提交的注释信息
9e7849fa0dbe 容器id
wangmin/gitlab:3.0 镜像名称:版本号
docker save b8c5a9990c6e > ./gitlab20190606.tag.gz
3.升级gitlab,使用
cp -ra
拷贝数据文件
4.chrome插件gitmaster
11.查看某container启动参数
docker ps --no-trunc -f name=X
12.更改容器环境变量1、
systemctl stop docker
后更改/var/lib/docker/containers/[container-id]/config.json
2、docker exec -it [container-name] env
查询环境变量,也可使用inspect命令
13.
docker login IP:Port -u ${username} -p ${password}
支持同时登录不同地址
14.K8s重启deployment下pod
kubectl scale deployment ${deploymentname} --replicas=0 -n ${namespace}
kubectl scale deployment ${deploymentname} --replicas=X -n ${namespace}
15.K8s deployment yaml配置中如含有特殊字符
$
可以使用$$
转义为$