Linux Docker环境常用命令

linux

systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
dhclient

git

git config http.postBuffer 524288000

DNS

vim /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=8.8.8.8

vim /etc/resolv.conf
nameserver 8.8.8.8

service network restart

docker

tar -zxvf docker-20.10.18.tgz
/bin/cp docker/* /usr/bin/
vim /etc/systemd/system/docker.service

#内容
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
 
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock  --icc=false
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
 
[Install]
WantedBy=multi-user.target


#添加service服务文件权限
chmod +x /etc/systemd/system/docker.service

#重载unit配置文件
systemctl daemon-reload

#启动Docker
systemctl start docker

#如果失败
vim /etc/sysconfig/selinux  把 selinux 属性值改为disabled。然后重启系统

#设置开机自启
systemctl enable docker.service

#查看Docker状态
systemctl status docker

#查看Docker版本
docker version

#配置仓库地址
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://jhn7rnah.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.60.3:5000"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

#限制容器日志参数
--log-opt max-size=500m  --log-opt max-file=3

#推送镜像到私有仓库
docker tag 镜像名 仓库地址/到仓库中的镜像名
docker push 仓库地址/镜像名

docker pull hyper/docker-registry-web

##命令注释
docker run                                 ##运行
-d                                         ##后台运行
-p 5001:8080                               ##端口映射
--name registry-web                        ##容器命名
--link registry                            ##连接其他容器  加入registry到host
-e REGISTRY_URL=http://registry:5000/v2    ##指定仓库地址
-e REGISTRY_NAME=localhost:5000            ##仓库命名
hyper/docker-registry-web                  ##被启动的镜像

-p 5001:8080 
--link registry            
-e REGISTRY_URL=http://192.168.60.3:5000/v2 
-e REGISTRY_NAME=192.168.60.3:5000

ES镜像

FROM centos:8
COPY ./elasticsearch-7.8.0-linux-x86_64.tar.gz ./
RUN tar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz
RUN groupadd -r es && useradd -r -g es es
RUN chown -R es /elasticsearch-7.8.0
USER es
WORKDIR /elasticsearch-7.8.0
ENTRYPOINT ./bin/elasticsearch
EXPOSE 9200
EXPOSE 9300

构建镜像
docker build -t es:1 ./

给宿主机挂载卷的目录赋权
chmod 777 -R ./config/

修改宿主机配置文件
vim /etc/sysctl.conf
在文件末尾增加下面内容
一个进程可以拥有的VMA(虚拟内存区域)的数量,默认值为65536
vm.max_map_count=655360
重新加载
sysctl -p

创建容器运行
docker run --name=es -p 9200:9200 -p 9300:9300  -v /root/es/config:/elasticsearch-7.8.0/config es:1

修改ES配置
vim ./config/elasticsearch.yml

修改ES内存占用
vim ./config/jvm.options
-Xms=1g
-Xmx=1g
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值