小编Dan*_*ver的帖子

docker 容器中的 tcp_keepalive_time

我有一个将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)

docker docker-swarm

9
推荐指数
1
解决办法
7249
查看次数

新 Linux 内核中的内存隔离,还是什么?

这个我的模块完美地劫持了用户的控制台: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)

c kernel-module linux-kernel

5
推荐指数
1
解决办法
527
查看次数

为什么零大小的类型在某些情况下会导致实际分配?

我正在使用零大小类型(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)

pointers rust

5
推荐指数
1
解决办法
130
查看次数

"Device or resource busy" when i try move /etc/resolv.conf in ubuntu:18.04. How fix it?

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.

ubuntu docker resolv

3
推荐指数
2
解决办法
4056
查看次数

在 /docker-entrypoint-initdb.d/db_init.sh 中运行 psql 命令时出错(psql:无法连接到服务器:连接被拒绝)

我曾经使用脚本 ( /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)

postgresql docker docker-compose

1
推荐指数
1
解决办法
924
查看次数