我有一个将net.ipv4.tcp_keepalive_time内核参数设置为 600的 docker 主机。但是当容器运行时,它使用不同的值:
$ sysctl net.ipv4.tcp_keepalive_time
net.ipv4.tcp_keepalive_time = 600
$ docker run --rm ubuntu:latest sysctl net.ipv4.tcp_keepalive_time
net.ipv4.tcp_keepalive_time = 7200
Run Code Online (Sandbox Code Playgroud)
这是为什么,我该如何更改此值而不必传递--sysctl选项?
--sysctl在我的情况下,我无法通过的原因是该主机是一个 docker swarm 容器,目前swarm不支持此选项。
但是容器不应该只从主机获取这些内核参数吗?我已经重新启动了 docker 服务(及其容器)。
编辑:一些额外的主机信息:
$ uname -r
4.15.0-38-generic
$ docker --version
Docker version 18.06.1-ce, build e68fc7a
Run Code Online (Sandbox Code Playgroud) 这个我的模块完美地劫持了用户的控制台:https : //pastebin.com/99YJFnaq
它是 Linux 内核 4.12,Kali 2018.1。
现在,我已经安装了最新版本的 Kali - 2019.1。它使用内核 4.19:
Linux kali 4.19.0-kali1-amd64 #1 SMP Debian 4.19.13-1kali1 (2019-01-03) x86_64 GNU/Linux
我试图捕捉任何东西,但流中不存在 fd == 0 的任何东西。
changelogs不同的资源......
我找到了这样的模块kpti,它可能会做类似的事情,但是这个模块没有安装在 Kali 2019.1 中。
请帮我找出hacked_read这段代码停止听到的确切原因sys_read():
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/syscalls.h>
#include <linux/version.h>
#include <linux/unistd.h>
#include <linux/time.h>
#include <linux/preempt.h>
#include <asm/uaccess.h>
#include <asm/paravirt.h>
#include <asm-generic/bug.h>
#include <asm/segment.h>
#define BUFFER_SIZE 512
#define MODULE_NAME "hacked_read"
#define dbg( format, …Run Code Online (Sandbox Code Playgroud) 我正在使用零大小类型(ZST),因为我很好奇它们实际上是如何在后台实现的。鉴于ZST不需要内存中的任何空间,并且采用原始指针是一种安全的操作,因此我很感兴趣,我将从不同种类的ZST“分配”中获得什么原始指针,以及结果的奇怪程度(对于安全的Rust)。
我的第一个尝试(test_stk.rs)是使用const指针指向ZST的一些堆栈实例:
struct Empty;
struct EmptyAgain;
fn main() {
let stk_ptr: *const Empty = &Empty;
let stk_ptr_again: *const EmptyAgain = &EmptyAgain;
let nested_stk_ptr = nested_stk();
println!("Pointer to on-stack Empty: {:?}", stk_ptr);
println!("Pointer to on-stack EmptyAgain: {:?}", stk_ptr_again);
println!("Pointer to Empty in nested frame: {:?}", nested_stk_ptr);
}
fn nested_stk() -> *const Empty {
&Empty
}
Run Code Online (Sandbox Code Playgroud)
编译并运行此程序将产生以下结果:
$ rustc test_stk.rs -o test_stk
$ ./test_stk
Pointer to on-stack Empty: 0x55ab86fc6000
Pointer to on-stack EmptyAgain: 0x55ab86fc6000
Pointer to Empty in nested frame: …Run Code Online (Sandbox Code Playgroud) I have a VPN client in my Docker container (ubuntu:18.04).
The client must do the following:
mv /etc/resolv.conf /etc/resolv.conf.orig
Run Code Online (Sandbox Code Playgroud)
Then the client should create new /etc/resolv.conf with their DNS servers. However, the move fails with an error:
mv: cannot move '/etc/resolv.conf' to '/etc/resolv.conf.orig': Device or resource busy
Run Code Online (Sandbox Code Playgroud)
Can this be fixed? Thank you advance.
P.S.: I can 't change the VPN client code.
我曾经使用脚本 ( /docker-entrypoint-initdb.d/db_init.sh) 在复制到 postgres 容器的文件夹中循环数据库转储并恢复它们。它曾经很好地工作,但最近它停止工作。
我收到以下错误:
postgres_server_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/db_init.sh
postgres_server_1 | --> db_init.sh: Found /dumps/dataset_1.dump as dataset_1
postgres_server_1 | psql: could not connect to server: Connection refused
postgres_server_1 | Is the server running on host "localhost" (127.0.0.1) and accepting
postgres_server_1 | TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)
该db_init.sh脚本循环遍历包含数据库转储的文件夹并检查数据库是否已存在。如果不是,它会恢复转储。
/docker-entrypoint-initdb.d/db_init.sh 内容:
shopt -s nullglob
for i in /dumps/*.dump;
do
db_name=${i##*/}
db_name=${db_name%.dump}
echo "--> db_init.sh: Found $i as $db_name"
if psql -U postgres -h localhost -lqt | …Run Code Online (Sandbox Code Playgroud) docker ×3
c ×1
docker-swarm ×1
linux-kernel ×1
pointers ×1
postgresql ×1
resolv ×1
rust ×1
ubuntu ×1