接上一篇 docker 容器安全与 firewalld;为了正常使用docker容器和firewalld,而不修改docker的daemon.json,按如下步骤个性firewalld规则,其本质上是修改ptables规则,修改完成后可以用iptables -nL
查看。
docker: 22 items found.
docker 容器暴露的端口不会因 firewalld 防火墙策略阻断!
最近发现一个问题,docker run 了几个容器,暴雷了 8080, 9090 等等几个端口,一直以为 CentOS 有 firewalld 防火墙在,加了这些端口只允许内网访问,就可以高枕无忧了。
结果有次查看 netstat,居然有一些国外的 IP 连接。这才知道原来有防火墙,容器也不安全!
Many times when writing Shell scripts, you may find yourself in a situation where you need to perform an action based on whether a file exists or not.
In Bash, you can use the test command to check whether a file exists and determine the type of the file.
The test command takes one of the following syntax forms:
test EXPRESSION
[ EXPRESSION ]
[[ EXPRESSION ]]
若有个名为nginx的容器:
docker run -it nginx bash
修改内容后退出,使用docker commit
命令提交修改。
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Create a new image from a container's changes
Options:
-a, --author string Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
-c, --change list Apply Dockerfile instruction to the created image
-m, --message string Commit message
-p, --pause Pause container during commit (default true)
如 :
docker commit -a "John Click" -m "add extra plugins" 2ff7f15ca033 nginx:latest
2ff7f15ca033
为刚才修改的docker容器id。
podman 3.0开始支持docker-compose,使用docker-compose up
时
需要先启用podman的api服务 systemctl enable --now podman.socket
注意那行Listen,可以执行 export DOCKER_HOST=unix:///run/podman/podman.sock
避免docker-compose运行时报出无法连接的错误:
Dockerfile需要传参时,如Dockerfile中有如下声明
ARG base_img=centos:latest
FROM ${base_img}
ARG arch=x86_64
COPY ${arch}/lib /usr/lib
RUN yum install -y nginx
...
在执行docker build
时可以通过参数--build-arg
进行传参,如
docker build . -t centos:latest -f Dockerfile --build-arg base_img=centos:7 --build-arg arch=amd64
docker 清除名称为none
的镜像
docker system prune
wsl无法使用,闪退。起初怀疑是wsl装的有问题,就将wsl按照 https://docs.microsoft.com/zh-cn/windows/wsl/install-win10 重新安装了一次。
安装了docker-desktop后 这个docker-desktop也是闪退。报出Failed to set version to docker-desktop: exit code: -1
这样的错误。
最终百度到:
powershell (管理员)下执行
netsh winsock reset
不用重启系统。即可。
这时docker-desktop也可以玩了。
前言
近2年Docker非常的火热,各位开发者恨不得把所有的应用、软件都部署在Docker容器中,但是您确定也要把数据库也部署的容器中吗?
这个问题不是子虚乌有,因为在网上能够找到很多各种操作手册和视频教程,小编整理了一些数据库不适合容器化的原因供大家参考,同时也希望大家在使用时能够谨慎一点。
目前为止将数据库容器化是非常不合理的,但是容器化的优点相信各位开发者都尝到了甜头,希望随着技术的发展能够更加完美的解决方案出现。
64位系统安装踩搞不少,很多apt都装不了,只能看官方有没有deb包,实在不行就需要编译安装。
可以从这里找docker的包
https://download.docker.com/linux/debian/dists/buster/pool/stable/armhf/
需要下载这三个 wget xxx