date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,364,456,540,000 |
for example, I have this command:
lxc launch ubuntu:18.04 memsql1
lxc exec memsql1 -- wget -O - 'https://release.memsql.com/release-aug2018.gpg' 2>/dev/null | sudo apt-key add - && apt-key list
lxc exec memsql1 apt-cache policy apt-transport-https
lxc exec memsql1 -- apt -y install apt-transport-https
lxc exec memsql... |
Nevermind, found it:
lxc exec memsql1 -- bash -c "the command with | pipe"
| How to run lxc exec for commands with pipe? |
1,364,456,540,000 |
I have 2 NICs: eth0 & eth1 on a host OS which runs some VMs (LXC) under it.
The hosts eth0 is connected to a private network and configured as the primary interface.
The hosts eth1 is connected to the DMZ.
Each VM has a static IP that bridges to eth0 on the host.
Some VMs, which need a public IP, have a 2nd virtual ... |
It should work, as long the interface is still up
ifconfig eth0 | grep UP
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
the bridge is a "switch" and it doesn't need to have one IP. But please check if you have firewall rules in eth0:
iptables -l -vnx
if rp_filter is off
cat /proc/sys/net/ipv4/conf/eth1/... | Can I have a bridged interface without an IP? |
1,364,456,540,000 |
I have a LXC container on my Debian system. I want to setup a public Git server on it so that it's accessible to other people. How can I do this?
UPDATE #1
Link to apache2.conf: http://pastebin.com/Nvh4SsSH.
|
Give this Howto a look. It's a little dated but should have the general steps you need to setup a Git server. The howto is titled: How To Install A Public Git Repository On A Debian Server.
General steps
Install git + gitweb
$ sudo apt-get install git-core gitweb
Setup gitweb directories
$ sudo mkdir /var/www/git
$ ... | How to setup Git server on Linux Container in Debian |
1,364,456,540,000 |
So according to the documentation on the Ubuntu LXC documentation the following statement can be found at the time of this writing:
A NIC can only exist in one namespace at a time, so a physical NIC passed into the container is not usable on the host.
Now one can have a single physical network card (NIC) share sever... |
It should be possible to assign eth0 and eth0:1 to different namespaces, but keep in mind there are security implications because you are exposing physical network device to your container.
Because of that, I would just use veth and bridge. Create a bridge br0 and bridge it with eth0 device by default. Then configure ... | LXC container to use "virtual" interface from host (namespace semantics) |
1,364,456,540,000 |
This question is similar to my question about how to list namespaces. So in addtition, I'd like to know some information about moving processes from one namespace to other? E.g. I have processes of current session in one namespace and some other processes of lxc container in different namespace, so I want to run (e.g.... |
You don't need to run process in some control groups if you already in certain namespace, instead you have to manipulate with namespaces. All new process in new namespace will «inherit» all control groups related to that namespace.
Moving processes between different namespaces can be done with setns() function or you ... | How to move process from one namespace to other? |
1,364,456,540,000 |
I successfully created an archlinux container on an archlinux host with lxc. However, whenever I start a container via
lxc-start -n GUESTNAME
the keyboard layout changes to the default us-layout on the host and in the container. But I want it to be de-latin1. What is surprising is that this keeps happening despit... |
This has been fixed in releases of lxc >= 1.1 with the introduction of the fuse-filesystem lxcfs. Simply install and set up lxc with lxcfs.
| Host system keyboard layout changes when starting LXC container |
1,364,456,540,000 |
I'm trying to setup a NFS server on an Alpine Linux LXC running on Proxmox by following the instructions as outlined here, but rpc.statd refuses to start. Here's an excerpt from /var/log/messages showing the error:
Nov 26 03:08:25 nfs daemon.notice rpc.statd[226]: Version 2.1.1 starting
Nov 26 03:08:25 nfs daemon.warn... |
It turns out I needed the CAP_SETPCAP capability to run the NFS server.
This can be done by editing the container's configuration file in /etc/pve/lxc/CTID.conf (where CTID is your container ID) as follows:
....
# clear cap.drop
lxc.cap.drop:
# copy drop list from /usr/share/lxc/config/common.conf
lxc.cap.drop = mac_... | Unable to start NFS server on Alpine Linux LXC |
1,364,456,540,000 |
I've made a new installation of Debian 11. Regarding LXC, I copied the working setup of my Debian 10 computer. I use a separate user, lxcuser which I su to, to lxc-start.
The configuration, ~/.config/lxc/default.conf
lxc.idmap = u 0 165536 65536
lxc.idmap = g 0 165536 65536
lxc.apparmor.profile = unconfined
lxc.mount.... |
The very last version of Debian bullseye LXC package (1:4.0.6-2 from Fri, 11 Jun 2021) somewhat lately warns about changes in starting unprivileged containers in Debian 11 using cgroup v2 and LXC 4.x:
lxc (1:4.0.6-2) unstable; urgency=medium
A new way of handling unprivileged containers starting and attachment has
b... | Cannot start unprivileged LXC containers on Debian 11 Bullseye |
1,364,456,540,000 |
Trying to start a Linux container, I get the following:
lxc-start: No cgroup mounted on the system
OS is Debian 7.
|
LXC (or other uses of the cgroups facility) requires the cgroups filesystem to be mounted (see §2.1 in the cgroups kernel documentation). It seems that as of Debian wheezy, this doesn't happen automatically.
Add the following line to /etc/fstab:
cgroup /sys/fs/cgroup cgroup defaults
For a one-time thing, mount it man... | lxc-start: No cgroup mounted on the system |
1,364,456,540,000 |
I'm looking for some reference documentation to explain what each of the settings are, for each control group.
For example, there's cpuset.cpus, I think setting this to 0 means use all CPUs, setting it to 1 limits you to 1 core. And cpuset.shares, how is that configured exactly?
Surely there's a reference doc that sim... |
A big thanks to Red Hat, I finally tracked down the reference documentation I was looking for in their documentation. I expect that there's no difference between Red Hat and other distros on this point.
Subsystems and Tunable Parameters | Red Hat Customer Portal
| Reference documentation for cgroups (control groups) settings |
1,364,456,540,000 |
I've got 2 LXC containers with these cgroup settings:
lxc.cgroup.blkio.weight = 200
lxc.cgroup.cpu.shares = 200
and
lxc.cgroup.blkio.weight = 800
lxc.cgroup.cpu.shares = 800
I have verified in /sys/fs/cgroup/blkio/lxc/test1-lxccontainer/blkio.weight is indeed set to 200 on the host OS.
I have verified that cpu.shar... |
The problem here is that you need to use the fair scheduler, I was using the wrong scheduler, and had mis-read a setting (thought I was using fair scheduler, but really wasn't). Swapping to the correct IO scheduler fixed the problem.
To change the IO scheduler (taken from here):
echo cfq > /sys/block/{DEVICE-NAME}/que... | cgroups: blkio.weight doesn't seem to have the expected effect |
1,364,456,540,000 |
I'm trying to make ansible set InnoDB buffer pool size to some percent of available memory. But ansible_memtotal_mb and free report how much memory the host has. How do I figure out how much memory is available from inside container? Container name is not known in advance.
UPD I'm running debian jessie, and pass cgrou... |
tl;dr
cat /sys/fs/cgroup/memory$(cat /proc/self/cgroup | grep memory | cut -d: -f3)/memory.limit_in_bytes
or
cat $(mount | grep cgroup | grep memory | cut -d' ' -f3)$(cat /proc/self/cgroup | grep memory | cut -d: -f3)/memory.limit_in_bytes
If your default container configuration allows host's cgroup info from within... | How to find out how much memory lxc container is allowed to consume? |
1,364,456,540,000 |
I'm using lxc to have a ubuntu 16.04 development environment on my 18.04 laptop. When I do a parallel build (ninja -j) on the container my computer becomes unresponsive and never recovers. I have to restart it when this happens. I know this is vague, I am suspicious this has something to do with memory usage or som... |
It sounds like your LXC host is running out of memory and the system is killing processes. You have a couple of options:
Add more memory or add a swap file / increase swap to your host
Limit your LXC dev container to one or more CPU cores to make parallel ninja builds less aggressive
For option 2, assuming you have ... | computer locks up when building on lxc container |
1,364,456,540,000 |
Debian 8.3,
LXC 1:1.0.6-6+deb8u2
When LXC downloads the base packages for a Debian container, are the packages verified? Verifying a Debian CD involves comparing signed checksum files against the checksum of the downloaded file (and also that the signature itself is valid) as described here. Apt also verifies packages... |
No. debian template for lxc-create internally uses debootstrap which certainly verifies downloaded packages against release signatures in the repository just like apt.
| LXC: Are downloaded templates verified? |
1,364,456,540,000 |
PROBLEM:
So I've been trying to get a usb device (primesense - the OEM reference for the Kinect) to passthrough to an LXC container so I can develop without worrying about polluting my stable system with experimental libraries.
I think I've done everything necessary, but applications running inside the container canno... |
Adding a whitelist rule through lxc-cgroup is not persistent, in testing my LXC containers I reset the container at some point and did not re-add the rule. The device node is created in the container correctly even without lxc white-listing (c *:* m is a default lxc rule) but the lxc container is denied access to the... | USB passthrough for LXC containers |
1,364,456,540,000 |
So far I am using various xautomation/xdotool scripts in a KVM virtual machine (linux guest) in order to let them do their work and let me work uninterruptedly. I am using a VirtIO disk, but still the performance of the guest is slow most of the times.
Can I do the same in an LXC container, e.g. using docker?
|
I can't say anything to the performance but in researching this I came across this SO Q&A titled: can you run GUI apps in a docker? that shows 3 methods for accomplishing this.
Running AppX over VNC
This method shows using the following Dockerfile:
# Firefox over VNC
#
# VERSION 0.1
# DOCKER-VERSION ... | X and xdotool in LXC instead of KVM |
1,364,456,540,000 |
I just installed lxc in Arch Linux, but the qemu-debootstrap binary seems missing,
This command sudo lxc-create -n test -t ubuntu -P /run/shm/1 complains about that.
I couldn't find it with either pacman or yaourt.
Any ideas how to fix that? I have the debootstrap script installed and that works though
|
Debootstrap is in aur/debootstrap package. After installation process you will have to make a symlink in /usr/bin:
cd /usr/bin ; ln -sf debootstrap qemu-debootstrap
After that do what ouzmoutous suggests.
Anyway I always advise to use downloaded templates.
HTH
| No qemu-debootstrap in Arch Linux |
1,364,456,540,000 |
(Please note that this question is about LXC 1.x, whereas this one is about LXC 2.x/LXD)
I scoured the web for an answer to this one, but couldn't come up with any reasonably non-hacky answer.
What I am looking for is an approach to fashion an existing template a way I'd like to. In particular what I'm after is to cus... |
On the linked page [5/12] by Stéphane Graber, you can find a second approach:
Manually building an image
Building your own image is also pretty simple.
Generate a container filesystem. This entirely depends on the distribution you’re using. For Ubuntu and Debian, it would be by using
debootstrap.
Configure anything ... | Creating a custom template, based on some existing LXC template after running the instance at least once |
1,364,456,540,000 |
I'm trying to provide a service to the LXC guests, but do not want to expose it from the host. I also don't want to put up firewall rules for the service, so loopback appears to be the most straightforward solution.
Is there a way to have a service listening on lo (loopback) shared with LXC guests, e.g. similar to bin... |
There are different ways to achieve your goal.
If the guests share a virtual network (i.e. are not just bridged to the physical interface) it's easy. Just tell your services to listen on that interface - or create a new guest and let that one host the service.
If the guests are bridged to ethX, you might still want to... | Is there a way to share a service listening on loopback of the host with an LXC guest? |
1,364,456,540,000 |
Is it possible to build ‘Linux From Scratch’ (LFS) inside of an LXC container, as opposed to creating a dedicated partition per the LFS instructions?
|
LFS run it's own kernel. In LXC container or any container based virtualization guest system shares the host's kernel. So LFS can't be run inside a container based VM.
Further in absence of dedicated kernel guest suffers several restrictions inside container. Like guest can't load it's own kernel module (i.e. drivers)... | Linux From Scratch Inside of an LXC Container |
1,364,456,540,000 |
I am trying to experiment with mount namespace in Ubuntu. So far I can create an empty mount namespace using the following:
# mkdir test
# unshare --mount
# mount none test -t tmpfs
# cd test
# pivot_root . .
# cd / <--- test becomes /
When I check a LXC Ubuntu container, the mount command displays the following:
S... |
To see what LXC actually does, let's create a new container and trace its startup process via strace(1):
[root@localhost /]# lxc-create -n testcontainer -t debian
[root@localhost /]# strace -e trace=clone,chdir,mount,pivot_root,execve \
-f -o lxclog \
lxc-start -n ... | How does LXC setup its root mount point? |
1,364,456,540,000 |
I have a number of ZFS sub-filesystems (so that I can granularly manage snapshots and ZFS options) like so:
tank/media
tank/media/pictures
tank/media/pictures/photos
tank/media/movies
tank/media/music
tank/media/documents
tank/media/documents/public
I am running Debian GNU/Linux 8.6 (jessie) with ZFS-on-Linux, kernel... |
I have found that mounting with the rbind (rather than bind) option in the lxc mount line solves the issue (syntax for proxmox):
lxc.mount.entry: /tank/media media none rbind,create=dir,optional 0 0
Going off the RedHat documentation on sharing mounts, rbind achieves replication of mounts on the source in the bound d... | How can I automatically make ZFS filesyatems mount shared / rshared? |
1,364,456,540,000 |
I normally create containers with:
lxc-create -n mycontainer -t debian
However I want to bake a few items into that "debian" default template.
New user with my ssh key, can sudo without a password.
Have python installed.
Basically this is the bare bones needed for ansible. I then want to provision my container via ... |
If you want to add a package, edit:
/usr/share/lxc/templates/lxc-debian
and search for download_debian(). Add your package to that section along with the other packages (I see ifupdown, locales, etc). If you make changes to the package list, you will need to clear the cache. I do that by doing:
rm -rf /var/cache/lxc/... | How do I make changes to an lxc template? |
1,364,456,540,000 |
TL:DR
How can I make a bridge permanent (survive reboot) without adding a network device to the bridge config in /etc/network/interfaces?
Hi, I just started playing around with lxc on ubuntu 14.04.
The setup I would like to accomplish is, one container with haproxy, one with nginx.
I will dnat external requests via ip... |
What about if you use bridge_ports none to get this working on boot, without the need to add members to this interface?
auto br-haproxy
iface br-haproxy inet static
bridge_ports none
bridge_fd 0
bridge_waitport 0
address 10.100.0.1
netmask 255.255.255.0
bridge_fd and waitport are s... | Setup permanent bridge for dynamic network devices from lxc container? |
1,573,048,801,000 |
I've (tried to) set things up to allow myself to have some unprivileged containers I can start (and then use) as needed.
Now I can create new containers with lxc-create, but when I try to start one, this happens
> lxc-start --name frisk-buster ... |
The "Quota reached" message was actually right. For some reason (Probably copy-paste from different sources, that did things differently even though I hadn't seen that), the configuration file for my container said to make an interface called virbr0, while the lxc-usernet configuration allowed me to create interfaces ... | lxc(-net ?) problems when starting container on debian Buster |
1,573,048,801,000 |
By default, Ctrl+Alt+F1-F6 lead to a virtual console.
A lxc container is running on my computer. How to configure the host so that Ctrl+Alt+F6 goes to the virtual console of the container?
Moreover, how to configure the host so that Ctrl+Alt+F6 goes to an x server running inside the container?
|
I've figured this out, mainly inspired by this post on arch forum.
Disable the getty currently running behind tty6 by removing /etc/init/tty6.conf, this would take effect after rebooting.
Allow the container to access tty6 by adding lxc.cgroup.devices.allow = c 4:6 rwm to the container's configuration
Autostart gett... | Ctrl+Alt+F6 to access a linux container? |
1,573,048,801,000 |
Is it possible to make ssh connection to lxc container by its name?
I have been using IP addresses but then I though how easy it would be to use ssh test01 (here test01 being container name) instead of remembering its IP address, or starting the container and looking its IP.
|
Create a file ~/.ssh/config, with contents:
Host test01
Hostname 192.168.3.1
Then chmod it to 0600 and enjoy. You can add any ssh_config(5) options there (changing the remote username is a particularly useful one), and youy can have as many Host sections as you like.
| How to make ssh connection to LXC container by its name? |
1,573,048,801,000 |
I'm trying to set up unprivileged LXC containers and failing at every turn. I think I've followed every relevant step of the guide:
Normal users are allowed to create unprivileged containers:
$ sysctl kernel.unprivileged_userns_clone
kernel.unprivileged_userns_clone = 1
The control groups PAM module is enabled:
$ gr... |
Is this a new project, or do you have a choice? Why not use LXD instead of LXC - much easier to use and you get to the same place. I started out with lxc and quickly made the switch because I was interested in running unprivileged containers which is not easy in LXC, but is the default in LXD.
Take a look here to st... | How do I configure unprivileged Linux containers? |
1,573,048,801,000 |
I have an LXC container running docker. Many containers are running successfully but I am unable to add more; I am trying to deploy a new docker container and getting the following error:
container init caused "join session keyring: create session key: disk quote exceeded": unknown
But the container has plenty of fre... |
It's not the root filesystem that's the issue here, it's the kernel keyring. This LXC thread explains it well, and has the following solution: on the LXC host (not inside the LXC container), raise the maximum number of keys with:
echo 5000 | sudo tee /proc/sys/kernel/keys/maxkeys
5000 is admittedly arbitrary; select ... | disk quota exceeded when trying to deploy Docker container inside LXC |
1,573,048,801,000 |
I am building a system with a read-only rootfs.
This rootfs is shared between the host and created containers.
The host cannot have any network related service or file and that means I cannot bridge the host connection.
I am currently using an USB network adapter.
How can I start this device and the network service in... |
Forget the network card as a specific hardware. Just consider you have a network interface and it has to be moved to a container. This is not USB or PCI pass-through. Let's call it interface pass-through and it's specifically handled by the network namespace logic using for example ip link:
netns NETNSNAME | PID
move... | Container with network interface but host without, how to expose eth0 to container |
1,573,048,801,000 |
So you configured your unprivileged LXC guest, by defining
lxc.id_map = u 0 1000000000 10000
lxc.id_map = g 0 1000000000 10000
and of course assigning those subordinate UID/GID ranges to an existing user (usermod --add-sub-uids ...).
However, whenever you ssh host you get:
Read from socket failed: Connection reset by... |
General troubleshooting advice for OpenSSH
First of all I refer you to this short troubleshooting guide for sshd which I am using as a recipe time and time again.
The plot thickens
Only difference in this case, I used lxc-console to attach to the guest, logged in and stopped the running sshd and then started my instan... | Can't connect to the sshd in my unprivileged LXC guest. What to do? |
1,573,048,801,000 |
I have a Lxc container inside a Proxmox host. I need to prevent that the Proxmox admin can login inside my container. To do so I disabled root login in /etc/passwd. When the Proxmox admin uses pct enter to login as root, the message "This account is currently not available" is correctly displayed.
I wish to add my cus... |
If the root login has its shell set to nologin, instead of logging in it runs the nologin command.
Check out the manpage of nologin for more information.
As pointed out in the manpage, you can create a text file at /etc/nologin.txt to display a custom message. Otherwise it will use the default message.
| Custom message to "This account is currently not available" when user login is disabled |
1,573,048,801,000 |
I have a need to point devices to sync their clocks to my CentOS-7 server running inside LXC.
On the server I'm trying to use ntpd from ntp package, but open to other products.
This question is about the setting up the ntpd or equivalent on the server.
So far I tried this in /etc/ntp.conf
driftfile /var/lib/ntp/drift
... |
As discussed in comments, chrony recently received a new option -x to not attempt to alter the system clock, making it especially suitable for container operations. Alas, the first version (3.2) to receive this option wasn't thorough and still requests the Linux capability, so still fails.
Stracing chronyd from packag... | How to run ntpd as a server only, without adjusting local machine time, under LXC |
1,573,048,801,000 |
I ran rm -rf on /var/cache/lxc, not realizing it was full of symlinks. I've lost a bunch of files, including most of /dev. I have a mlocate.db from 16 hours ago. How do I compare the list of files from mlocate.db to what still exists to get a complete list of what is missing? locate -e says it will give me files t... |
Make a backup copy of /var/lib/mlocate/mlocate.db now, before the mlocate updatedb cron job runs again.
Dump mlocate.db to a text file:
mlocate / | sort > /var/lib/mlocate/mlocate-old.txt
Update your your mlocate.db. How to do this varies slightly according to what kind of unix clone or linux distribution you're usi... | How do I compare mlocate.db to what exists now? |
1,573,048,801,000 |
Context
In my "quest" to get LXC to run on Raspbian I may be forced to disable loading the seccomp configuration at container startup, by commenting it out in /usr/share/lxc/config/debian.common.conf:
# Blacklist some syscalls which are not safe in privileged
# containers
# lxc.seccomp = /usr/share/lxc/config/common.... |
Well, the seccomp rules prevent a container from modifying the host kernel. Without them, UID 0 in a container can use kexec(if that even works on Raspbian, I'm not sure) to load a new kernel(apparently not to start it) and insmod/rmmod to load/unload modules among other things as these syscalls don't take user namesp... | How dangerous is it not to load `seccomp` rules for LXC containers? |
1,573,048,801,000 |
By mistake, I deleted an lxc image file. The container is still running and the file is therefore not yet actually deleted until I stop the container. I'd like to avoid stopping the container as it is quite sensitive.
I tried to find the deleted file with:
for i in $(ls /proc/|grep '^[0-9]*$'); do ls -l /proc/$i/fd|gr... |
[not a complete answer, but too long to put in a comment]
You can find the inode of a (possibly deleted) backing file of a loop device with the LOOP_GET_STATUS or LOOP_GET_STATUS64 ioctls: it's the .lo_inode field of the loop_info and loop_info64 structs.
As I wasn't able to find any command line utility exposing that... | Recover deleted but mounted loop file/filesystem |
1,573,048,801,000 |
NB: This question relates directly to this one and in particular to this answer, but it's not a duplicate.
I'd like to share a folder from the host with the guest, but make sure that the guest's root cannot accidentally write to that folder.
The folder in my case is /toolchains, both on the host and the guest. And it ... |
What happens if you bind-mount your directory read-only on the host and then share it with the LXC container?
mount --bind /toolchains /toolchains-ro
mount -o remount,ro,bind /toolchains-ro
lxc config device add CONTAINER toolchains disk source=/toolchains-ro path=toolchains
Technically everything what is read-only o... | Mount host folder to guest with LXC 2.x, but do it readonly? |
1,573,048,801,000 |
I want to run a program inside a container with a specific user. By default, when using lxc-attach, the user is root, but I don't want to execute the program as root.
Command I want to execute:
lxc-attach -n container -- python3 some_program.py
When attached to the container, I want the user to be uid=1000 not uid=0 ... |
You have to use su to change the user:
$ sudo lxc-attach -n test -- su ubuntu -c 'whoami'
ubuntu
Your command would look like this (if you don't know the username):
lxc-attach -n container -- 'su $(getent passwd 1000| cut -f1 -d:) -c "python3 some_program.py"'
| Running a program inside an LXC container with a specific user |
1,573,048,801,000 |
If I run top on the guest, the load average values seem to be exactly the same as running top on the host.
Is a Docker (LXC) guest's load average the same as the host's load average?
|
Looking at the code for /proc/loadavg - yes, it's the same. The load average is read out from global variables.
seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
LOAD_INT(avnr... | Is an LXC guest load average the same as the host's load average? |
1,573,048,801,000 |
I want to use LXC to 'container' plugins my application is loading. Am I able to do this through C? I have been Googling a lot about it, but there don't seem to be any headers, only scripts that can be called through the terminal.
I know I can execute the scripts inside C, but I'd rather use the headers if there are ... |
If you look at the LXC homepage, you'll notice liblxc referred to, implying there's an ABI, and if you look further down, you'll notice a link to the C API documentation.
That page looks empty at first because it has been done (rather lazily, I think) with doxygen. However, if you start clicking around you'll find st... | Can you use LXC through C? |
1,573,048,801,000 |
Debian 12.2 in an unpriviledged LXC (proxmox). It's almost 11:45 AM local time. At 5:00 AM in the morning, cron started a script:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
jan 26633 0.0 0.0 8500 2056 ? S 05:00 0:00 /usr/sbin/CRON -f
I'm using pgrep -f CRON -O 600 a... |
LXC mounts a fake /proc/uptime to simulate the uptime of the container rather than the host's uptime, since this property is not namespaced. Here on a (root) LXC container:
# findmnt /proc/uptime
TARGET SOURCE FSTYPE OPTIONS
/proc/uptime lxcfs[/proc/uptime] fuse.lxcfs rw,nosuid,nodev,relatime,us... | Why does "pgrep -O 600" fail in an LXC? procps bug? |
1,573,048,801,000 |
I have a bridge network br0 that has the IP 10.0.0.1/24, I have a client connected with the IP 10.0.0.2 to it. I also have a VPN connection (tun0) that has an IP assigned by an DHCP, so it's IP may vary. The VPN connection is not the default route of the system, therefore all the traffic on the device goes trough the ... |
So at the end I finally found the missing settings thanks to the suggestions of @Fiisch.
Here is the final commands to make it work:
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -A FORWARD -i br0 -o tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -o br0 -j ACCEPT
iptables -A INPUT -i tun0 -m state --stat... | How to route traffic from br0 to tun0 when tun0 is not the default route of the system |
1,573,048,801,000 |
I know that the command $ lxc-snapshot exists somewhere, but it seems that it's not available on Debian? Forgive my Linux ignorance - but how do I get a hold of this capability? Is there an alternative for Debian?
Also, if you need this info, the result of $ uname -a:
Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+... |
lxc-snapshot is listed in the version of lxc in testing/unstable, which at this time of writing are both the same, namely 1:1.0.6-6.
You can see the list of packages at
File list of package lxc/jessie/amd64.
Backporting lxc should not be a problem. It does not have much by way of dependencies. Comment if you need more... | Snapshotting a Linux container in Debian |
1,573,048,801,000 |
I'm trying create a nice playground for Docker in Vagrant based on Vagrant's precise64 box. (Code is available at GitHub: rfkrocktk/docker-vagrant-playground)
Here's my Puppet provisioning dependencies for the instance:
# Puppet for Docker Vagrant Box
node default {
# apt
class { 'apt': }
apt::source { 'd... |
Evidently, Phusion packages their own Ubuntu 12.04 Vagrant boxes which run the required 3.8 kernel to make it easier to use Docker. They also provide the memory and swap accounting kernel init parameters to make these features available to LXC.
To use these boxes, simply update the box name and URL in your Vagrantfile... | Creating a Vagrant box with Docker installed |
1,573,048,801,000 |
I'm using LXC containers, and resolving CONTAINERNAME.lxd to the IP of the specified container, using:
sudo resolvectl dns lxdbr0 $bridge_ip
sudo resolvectl domain lxdbr0 '~lxd'
This works great! But the changes don't persist over a host reboot.
(I've described 'things I've tried' as answers to this question, which h... |
The LXD docs describe a solution:
Put this in /etc/systemd/system/lxd-dns-lxdbr0.service:
[Unit]
Description=LXD per-link DNS configuration for lxdbr0
BindsTo=sys-subsystem-net-devices-lxdbr0.device
After=sys-subsystem-net-devices-lxdbr0.device
[Service]
Type=oneshot
ExecStart=/usr/bin/resolvectl dns lxdbr0 BRIDGEIP
... | Persist resolvectl changes across reboots |
1,573,048,801,000 |
From everything I have read in the unshare and nsenter man pages, I should be able to bind-mount a directory to itself, mount --make-private the directory, and then use files within that directory to hold refs for persistent namespaces. Here is what I'm doing, basically the same as the man unshare but with different ... |
There is a bug between before util-linux v2.36 that was patched in this commit:
0d5260b66 unshare: Fix PID and TIME namespace persistence
Use a version of util-linux containing the patch!
Here is a test-script to verify if you have this bug:
umount -l /mnt/jails/*/*/.ns/* /mnt/jails/*/*/.ns/
sleep 1
mkdir -p /mnt/jai... | Why is the Linux command `unshare --pid=p --mount=m` not creating a persistent namespace? |
1,573,048,801,000 |
I am running openstack on LXC container and i found inside my LXC container network is very slow but from host its very fast
HOST
[root@ostack-infra-01 ~]# time wget http://mirror.cc.columbia.edu/pub/linux/centos/7.5.1804/updates/x86_64/repodata/0d7e660988dcc434ec5dec72067655f9b0ef44e6164d3fb85bda2bd1b09534db-primary.... |
Solution
Host machine had following setting, it was causing my dmesg flood with lots of kernel error stack. (7 - debug level).
[root@lxc ~]# cat /proc/sys/kernel/printk
7 4 1 3
I have changed it to:
[root@lxc ~]# cat /proc/sys/kernel/printk
3 4 1 3
Later I found I had iptables --checksum-fill rules in i... | LXC container network speed issue |
1,573,048,801,000 |
I have my rootfs snapshot in /mnt/mydisk/my_test_snapshot. It is completely writable copy of my current system.
I want to boot a virtual machine (possibly an LXC container or maybe something else) that will use /mnt/mydisk/my_test_snapshot as its root (/) folder.
At the end, I need to boot a virtual machine that:
... |
As a partial answer, I created the following tool to create an LXC container from a subvolume: https://github.com/aktos-io/lxc-to-the-future
if [[ "$(grep br0 /etc/network/interfaces)" == "" ]]; then
cat <<ONETIME
ERROR: No br0 bridge device found in /etc/network/interfaces file.
Edit your /etc/network/interfac... | How to boot a virtual machine from a regular folder? |
1,573,048,801,000 |
I'm playing around with LXC on my Arch Linux workstation as a learning experience. I'm following the guide on the LXC page on the Archwiki and setting up a static ip for the container. This is what my network config is like:
/etc/netctl/lxcbridge
---------------------
Description="LXC Bridge"
Interface=br0
Connection=... |
So after a little bit more research I've determined why this is happening. I'm using the default Ubuntu and Debian templates to create the containers and their networking is set up so as to use DHCP to ask for a IP from the the router. So initially the static IP is set using the lxc.container.config and then when the ... | LXC container gets two IP addresses assigned to it |
1,573,048,801,000 |
I want to create a set of containers for simulating network traffic. Inside each of the containers, I would like to set a different network delay. Right now I am doing it manually using this command, after logging into the container:
sudo tc qdisc add dev eth0 root netem delay 128ms
I want it to be done automaticall... |
lxc-attach allows you to run a command in a container without logging in.
lxc-attach -n container-name -- <command>
So I guess you need to run:
lxc-attach -n container-name -- sudo tc qdisc add dev eth0 root netem delay 128ms
the output of the command, if any, is redirected to your standard outputs.
| What is the correct way to start a container with a given command? |
1,573,048,801,000 |
I rent a dedicated server and want to use LXC instead of KVM. I want to buy IPs for every single container. For now i have two external IPs:
193.X.X.30/32
213.X.X.31/32
I prefer a routing solution instead of NAT.
My last try is like this:
-------------------
| INTERNET |
... |
I don't know this is the right way or best solution but it works without NAT. The network topology is the same. We have one physical NIC (em1) and multiple IP for every container. Maybe later i can buy a subnet. But for now i'll buy 4 - 5 IPs.
-------------------
| INTERNET |
... | LXC external IP configuration for containers |
1,573,048,801,000 |
I am trying to do a more complicated task inside a running lxc ubuntu container, but my problem can be explained using this simple example. When I run
sudo lxc-attach -n container1 -- echo "test" > test.txt
inside of a shell script, I expect to find test.txt inside of my container, but instead I find it on my host ma... |
After some playing around I figured out the issue. I'll leave my question and answer here for the poor soul who inevitably runs into the same problem in the future and finds this question.
The key is to only attach to the container when accessing the file, not before running the whole command. Counterintuitively, the ... | Command executing outside container with lxc-attach? |
1,598,624,210,000 |
From yesterday I'm struggling with problem with LXC containers and limiting CPU resources per container. In my case command like lxc-cgroup -n srv50 cpu.shares 100 doesn't bring any results - containers still use CPU equally.
I'm using Centos 7 & LXC 1.0.8. All machines where I was checking that had the same effect: ... |
Yes, the issue in this case was with testing this feature. It works as expected. The only one issue I had on other cloud VM with 2 cores. As I don't need it, I won't be thinking about it any more. :) Cheers!
| LXC cpu.shares doesn't work |
1,598,624,210,000 |
Server: Ubuntu 16.04 Server, x64, no internet connection
I have LXD installed but am having trouble getting an image to that server to use as a baseline for containers. I have tried two options so far, with failed results.
1) Export image (Xenial)(meta.tar and rootfs.tar) from machine with internet and burn to cd.... |
Update: Tried the exact same 2 methods with the same files on a newly created VM and BOTH worked just fine. Issue must be in my VM, therefore I will be migrating to a new (working) VM.
Edit: The root cause actually lies somewhere in xen-guest-tools that provide additional functionality while running on Citrix XenS... | Create LXD containers on machine with no internet connection |
1,598,624,210,000 |
I am having the following configuration:
I have 5 LXC containers that are running nginx. On each container there are a couple of virtual hosts set up in nginx. That means for a container I have multiple virtual hosts that are available through port 80.
Each container has an IP like 10.0.3.100, 10.0.3.101, etc.
On the ... |
This is a reverse-proxy and the directive you are looking for is proxy_pass. The host instance of nginx will have multiple server containers like:
server {
listen 80;
server_name d1.example.com;
location / {
proxy_pass http://10.0.3.100;
proxy_set_header Host $host;
proxy_set_heade... | Nginx virtual hosts for multiple LXC containers |
1,598,624,210,000 |
Docker is based on Linux containers and control groups. But I would like to know which implementation of Linux containers , docker is using? Is it using the native/default (LXC execution environment ) of Linux or they have their own implementation of this?
|
Docker uses their own libcontainer library after they switched from using LXC in 2014.
LXC uses their (www.linuxcontainers.org) liblxc library.
Both libraries utilize the linux kernel namespaces technology.
LWN had a multi-part blog on namespaces: https://lwn.net/Articles/531114/
| Which container implementation docker is using |
1,598,624,210,000 |
lxc-autostart won't start unprivileged containers in Debian 11 Bullseye.
Start of unprivileged container in Debian 11 Bullseye was solved in this
answer by using lxc-unpriv-start instead of lxc-start but I was not able to take advantage of this approach when using lxc-autostart.
|
Basic solution
OK, so after few sleepless nights I ended up with a simple systemd unit file for each container. An example one may look like this:
[Unit]
Description=Linux container my-container-name
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/lxc-start -n my-container-name
ExecStop=/usr/bin/lxc-st... | Cannot autostart unprivileged LXC containers on Debian 11 Bullseye |
1,598,624,210,000 |
Here is the origin of my question:
I'm running Linux containers with LXD snap version at Ubuntu 22.04 on a VPS. The root file system of the VPS is Ext4 and there is not additional storage attached. So the default LXD storage pool is created by the dir option.
When I'm taking a snapshots of these LXCs, the whole data... |
It possible to do something like fallocate -l 16G /lvm.fs, then format it as LVM, mount it and use it as storage pool for LXD? And of course, how can I do that if it is possible?
Start by making your file. I like to place it in a directory other than /, so I created a /vol directory for this purpose:
truncate -s 16G... | Is it possible to use a file as Filesystem? |
1,598,624,210,000 |
I'm having hard time reading the output of ip a command.
Normally it prints something like this:
3: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff
Which is fine.
But inside the LXC container (not a... |
You have interfaces that are part of separate macvlans.
The output of ip listed above indicates that your host has two interfaces configured such that each interface, eth0@if12 and eth1@if14 are each a member of a separate macvlans configured in bridge mode (one physical interface to multiple virtual network interface... | ip address "@" (at) in output |
1,598,624,210,000 |
Can I install Docker on Red Hat server 5.9 so I can take an image container from an installed software and move it to another server?
Or should it be enough to update the Kernel up to version 3 so Docker can run?
|
Docker's website states that it can be installed on any 64 bit distribution of RHEL.
However, the kernel must be 3.10 at a minimum.
Check your kernel version first with the following command: uname -r.
| Docker container on Red Hat Linux server 5.9 |
1,598,624,210,000 |
Does a virtual bridge (added to /etc/network/interfaces) limit the transfer speed of data from the memory of one lxc/docker container to another?
For example does the memory throughput drop to that of 1G/10G Ethernet or is there no significant difference? That is would the throughput between two processes running on t... |
Virtual interfaces do not artificially limit throughput to a particular data rate, like a physical interface would. However, they do incur software overhead, so you should expect transfer rates to be lower compared to simpler inter-process communication mechanisms, unless the bottleneck is some other factor.
| What is the network connection speed between two containers communicating via a virtual bridge running on the same host? |
1,598,624,210,000 |
We are using a Centos LXC container with the rootfs contained in a squashfs filesystem. I really like the fact that a user cannot edit the rootfs from the host.
During the development, developers would infact like to make changes to the filesystem, and I'd like to move to an overlayfs. But I notice that although the u... |
lxc.pre.mount gets executed before the rootfs gets loaded:
lxc.hook.pre-mount = /var/lib/lxc/container0/mount-squashfs.sh
lxc.rootfs.path = overlayfs:/var/lib/lxc/container0/rootfs:/var/lib/lxc/container0/delta0
And in the mount script:
#!/bin/bash
mount -nt squashfs -o ro /var/lib/lxc/container0/rootfs.sqsh /var/lib... | LXC Container with Overlayfs/Squashfs |
1,598,624,210,000 |
I've installed a Proxmox VE 5.1 on a VirtualBox in macOS (10.12).
The guess OS, Debian Strech (Proxmox is built on debian), has 2 "physical" network interfaces (configured from VirtualBox), Host-Only and NAT, I can access to internet through the NAT interface:
root@proxmox:~# traceroute 1.1.1.1
traceroute to 1.1.1.1 (... |
In order to make routing from a VM work you need
a correct routing configuration on the host (which seems to be the case here)
to enable routing in general via /proc/sys/net/ipv4/ip_forward (which can be done on a permanent basis with the distro network tools or directly in /etc/sysctl.*)
to allow the routing of pack... | Internet access from LXC containers in proxmox 5.1 on VirtualBox |
1,504,805,717,000 |
I am trying to use chroots under lxc for development. I have enabled the "nesting" option in the lxc container configuration and bound mounted proc and devpts into my chroot as I would if the chroots were on a normal Linux box.
Unfortunately when I try and use stuff in the chroot that needs ptys (for example the "scri... |
The fix for this (found by educated guesswork) was to execute the following commands in the chroot.
rm /dev/ptmx
ln -s /dev/pts/ptmx /dev/ptmx
I'm not 100% sure but I believe the reason this is needed is that lxc is using "multiple instance mode" for /dev/pts . As per the documentation at https://github.com/torvalds/... | ptys not working in chroot under lxc |
1,504,805,717,000 |
In a web application I'm developing, users will be able to upload java code and I will need to compile and run that. For security reasons, I'd like to that inside an LXC container, and for footprint reasons I'd like that to be a busybox. So, I created a busybox container successfully with:
lxc-create -n my-box -t busy... |
As it turns out, the problem was the same as here: I still had to unpack the *.pack files from the lib and jre/lib folders in the java installation. unpack200, the program used to unpack *.pack files to .jar files isn't available in busybox, but it's shipped with java.
| Installing Java JDK in busybox in an LXC container - java/lang/NoClassDefFoundError: java/lang/Object |
1,504,805,717,000 |
I'm having trouble with sending shutdown -h 0 to a lxc Debian container (i.e. executing this command in the lxc) with with the python pexpect module (in a python script). In this module the user can "expect" (= wait for process output) a certain substring, amongst others EOF, which leads me to the question in order to... |
EOF indicates that no further input is to be expected on a resource which possibly provides an endless amount of data (e.g. a stream). This situation is often expressed by writing a single character on the stream (to be defined by the underlying system (likely a OS or runtime environment )).
As processes use streams f... | Do all Linux processes write EOF to stdout when they are terminating/have finished terminating? |
1,504,805,717,000 |
Summary: I have a mail server (exim 4, Debian 10) in an LXC container. The host is running Debian 11. Since yesterday evening spam traffic has been coming in that appears to come from the LXC Host. However, tcpdump logs show that it is actually remote traffic. What is going on?
This is an example of an exim4 log entry... |
I think the problem was caused by an iptables rule on the host
iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
This rule is intended for containers without an external IP to reach the internet.
What this rule does is masquerade any traffic going out through br0. It could be traffic going out from the host to a ... | Remote SMTP traffic appears to come from LXC Host to container |
1,504,805,717,000 |
Today I modified an LXC container to add an extra "bind mount", but forgot to create the mount directory in the container root filesystem.
As a result the container startup failed, and left the system in a strange state.
The startup had already created the "veth" interface for the container, and renamed another interf... |
This had created two separate issues - a stale "veth" pair, and a physical interface not being named correctly.
I solved the issue by combining bits of this post:
https://stackoverflow.com/questions/31989426/how-to-identify-orphaned-veth-interfaces-and-how-to-delete-them
for the "veth" issue, and this post:
CentOS 7 -... | How to cleanup network interfaces after an LXC container crashes on startup |
1,504,805,717,000 |
I also submitted this as a Fedora bug question, here.
I'm not sure if this is a bug, but here is my sudden issue.
The Linux/LXC single-box cluster setup
I use Fedora x86_64 (currently Fedora-25) as the LXC/HOST O/S. I use
CentOS-6 x86_64 (currently CentOS-6.9 Final) for the six (qty. 6)
LXC/GUEST O/S'.
This was worki... |
Thanks to the accepted answer in this POST, I was able to finally figure out the iptables(1M) entries that were missing. Here they are:
sudo iptables -A INPUT -i eth0 -j ACCEPT
sudo iptables -A INPUT -i br0 -j ACCEPT
sudo iptables -A FORWARD -i br0 -j ACCEPT
I don't know what Fedora HOST O/S changes occurred to make ... | Fedora-25 HOST + CentOS-6 GUESTS Linux/LXC: Guests can't connect to each other or to default router |
1,431,619,835,000 |
I'd like to archive an existing LXC container that has been configured to run as unprivileged LXC container (see this question).
How can I conserve all the file system meta-data that is used to store the mapped UID and GID for file/folder ownership?
NB: I know that the mapping itself happens on the host, but what I me... |
I have investigated that topic since I asked my question and it turns out that the ranges of sub-GIDs/sub-UIDs are indeed used as file-group/-owner for the files. There is no additional metadata (unless you'd be using SELinux or the like) which is relevant to this.
Also keep in mind that ACLs may have to be modified, ... | How do I conserve the userns UID/GID mappings when archiving an LXC guest? |
1,431,619,835,000 |
To generate images LXD compresses files using gzip, which can only use one core. Thus, creating images can be very slow with large containers. I would like to use other compressors (e.g., pigz). What options I have to speed up the creation of images? A similar question was discused in this mailing list. However, that ... |
You say "files". It is possible to compress files in parallel, using a non-parallel compressor. But this will require modifying the code that calls the compressor (does it have an option to do this already?).
Using a parallel compressor for each file, may be possible, but compression ratios will be reduced. e.g. indep... | It is possible to use parallel compression method in lxc publish? |
1,431,619,835,000 |
I have several lxc containers that need network access. At the moment I am manually allocating them IP addresses in the relevant config file as so:
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = eth0
lxc.network.link = br0
lxc.network.ipv4 = 192.168.1.6/24 ... |
Make sure netctl and dhcpcd is installed inside the container (pacman -Q netctl dhcpcd) then run the following in the container:
cat > /etc/netctl/eth0
Connection=ethernet
IP=dhcp
Interface=eth0
Press CTRL-D to write the file. Then enable the profile by running:
netctl enable eth0
Finally restart the container and y... | Set up DHCP for LXC containers |
1,431,619,835,000 |
When trying LXD, I tried to share a folder from my computer with the LXC Container, but I could not write in the folder in the container because ls -l shows that it belongs to user nobody and group nobody.
How to know the ID of this user and group?
|
You can also use the id command to lookup uids and gids:
# Get the numeric uid of the user 'nobody'
$ id -u nobody
65534
# Get the numeric gid of the user 'nobody'
$ id -g nobody
65534
With no options, it'll print the uid and all the gids to which the user belongs:
$ id nobody
uid=65534(nobody) gid=65534(nogroup) gr... | What is the ID of nobody user and nogroup group? |
1,431,619,835,000 |
I'm trying to make use of Ansible for configuration management and centralized administration.
All the machines I'm interested about are actually containers on the host which is going to run Ansible.
Currently I am writing a dynamic inventory script that groups the different hosts and makes certain hostvars available ... |
If I understand correctly you need to access some ansible variables defined for a generic host. You can access all hosts variables by the dictionary hostvars, that has hostname as primary key, for your example:
{{ hostvars['foo']['ipv4']['address'] }}
Credits goes to:
https://docs.ansible.com/playbooks_variables.htm... | How can I reuse the Ansible inventory for local tasks? |
1,431,619,835,000 |
I have an lxc-container with eth0 and IP 172.17.0.2/16. The host has a bridge br0 with 172.17.0.1/16. Both can ping each other. Further, the host has a VPN wg0 and IP 172.16.0.1/16. If I ping from inside the container to the VPN I get:
# ping 172.16.0.1
PING 172.16.0.1 (172.16.0.1) 56(84) bytes of data.
64 bytes from ... |
Unless I am mistaken, all local addresses (those belonging to the host) will react to a ping from any interface. It's not a question of forwarding, it's a question of recognizing the destination address as one of the local ones.
You can test this with tcpdump, and I would expect no packets to show up on wg0. You can a... | Why can some container ping an interface of the host which is not inside same LAN? |
1,431,619,835,000 |
I am pretty green when it comes to grep, can someone point out how I can get an array in bash of the list of snapshot names (NOTE: just the names) when I do a lxc info mycontainer ?
My current results are:
root@hosting:~/LXC-Commander# lxc info mycontainer --verbose
Name: mycontainer
Remote: unix:/var/lib/lxd/unix.soc... |
With lxc list --format=json you get a JSON document with a lot of information about all the various available containers.
lxc list mycontainer --format=json limits this to the containers whose names start with the string mycontainer (use 'mycontainer$' for an exact match).
Parsing JSON is generally safer than parsing ... | Get Array of LXD Snapshot Names |
1,431,619,835,000 |
I'd like to connect to a LXC container through Proxmox via SSH without having SSH access to the container itself, so I can get the desired outcome by connecting to the Proxmox host first and then running lxc-attach <ID> to connect to my container.
Now I'd like to do this in one go. For this I have a function in my rc ... |
Add the "-t" option to your ssh invocation:
sshc() { ssh -t $1 "lxc-attach $2; bash -i" }
When ssh is invoked with a command to run on the remote system, it doesn't allocate a TTY for the session by default. Adding "-t" tells ssh to requesta TTY for the session.
Interactive sessions normally operate through a TTY to ... | How to SSH to a host and attach an LXC container in one command, properly? |
1,431,619,835,000 |
On my host Ubuntu 18.04 I am running two lxc containers using default setups. Containers use Ubuntu 18.04 as well. I have an app running on container1 that offers an https based service on https://localhost:3000/. Container2 is not able to even establish a connection with container1.
Container2 can ping container1 and... |
Port 3000 is only listening for localhost. You need to configure your application correctly so that the port is open to 0.0.0.0 (as you can see in other ports).
| Connection refused between 2 linux containers |
1,431,619,835,000 |
I have problem with bind problem with lxd init. The port 8443 is not used by any other application, therefore I think, lxd init tries to bind this port twice.
My lxd version is 3.14 and I am using Gentoo.
Do you have any idea how to solve this please?
alpha /var/log # lxd init
Would you like to use LXD clustering? (ye... |
More than likely you will need to update your version of lxd to 3.19 or higher; searching through bugs and issues brought me to this thread:
github.com/lxc/lxd/issues/6682
netstat will show not any process listening on 8443 and it sounds like there is no configuration that might be pear-shaped. It simply looks to be a... | lxd init: bind: address already in use |
1,431,619,835,000 |
I am trying to explore the page fault behavior of Linux.
I made an lxc container with restricting the memory to 1GB
(by adding 'lxc.cgroup.memory.limit_in_bytes = 1G' to /etc/lxc/default.conf).
Then, I ran a simple code which accesses 2GB amount of data.
int main() {
char* buf = malloc(1024*1024*1024);
char* buf2 ... |
I figured out the problem.
A major problem with my code was that on first write to the malloc'ed page, page fault does not occur because Linux does not have to read an empty page from the disk. I changed the code so that it runs the looping part of the code twice.
Also, I disabled Linux readahead (by echo "0" >> /pro... | Why am I not seeing as many page faults as I expect? |
1,431,619,835,000 |
I have a system with Proxmox VE 5.1 and a LXC container with Fedora 27.
The container has 2 disk (raw format), the rootfs and an additional mount point, both of them are in ext4, I want to format to xfs the second mount point.
I've tried to use the typical mkfs.xfs but I don't know where the linux block device is stor... |
In your example, the block device is /dev/loop7; It's a loop device backed by the file /var/lib/vz/images/111/vm-111-disk-2.raw. Per Wikipedia:
In Unix-like operating systems, a loop device, vnd (vnode disk), or
lofi (loop file interface) is a pseudo-device that makes a file
accessible as a block device.
There's... | Format a raw image to XFS in Proxmox VE |
1,431,619,835,000 |
I have problem for past several months which was progressively getting worse and now I'm in state that if I try to do almost any intensive IO operation on my visualization host (Proxmox ve 5.1-41) like backup or even cp/rsync, dd speed of given transfer will drop to KB/s and server will hang pretty much indefinitely g... |
It sounds as though you are having a similar problem described by various people over the last 8 or so months. In essence the version of ZFS shipped with Proxmox 5.1 is reported to have a bug which in certain circumstances results in crippling high IO. (search z_null_int high disk I/O #6171)
Two current options are t... | High IO on KVM/LXC host will hang server but not on guest (Proxmox/Debian) |
1,431,619,835,000 |
i set up lxd on my host system with lxdbr0 bridge as nic. Now my containers get their ip addresses via dhcp from lxdbr0 (in the range of 10.204.x.x).
Also i have 2 public ip addresses. One for the host (x.x.x.x) and one for the container (b.b.b.b). The container should use the second public ip for outgoing and ingoing... |
All you need to do is to NAT the traffic coming from the container's private IP to the host's interface for the container's public IP ($publicIP2):
iptables -t nat -A POSTROUTING -s 10.204.119.5/32 -j SNAT --to-source $publicIP2
| Route outging traffic from private network (lxdbr0) |
1,431,619,835,000 |
From my understanding on container technology (like lxc or docker), when you create a container it by default uses a "private network" like 10.0.1.x.
I do not understand why you would not want it on the same NAT as your host OS. Why would you not want your container to be bridge on your primary network interface by d... |
Setting up a bridge is extra work. Someone has to do this work. Since some containers should be bridged and others shouldn't be bridged, container utilities don't systematically set up a bridge.
It's very common for a container not to be bridged. The point of a container is to isolate the container from the rest of th... | Why would a container not be bridged to the local network by default? |
1,431,619,835,000 |
I'm trying to get to grips with Incus, because it looks like it is a fork of Canonical's LXD, which I can run fairly easily on Debian 12 with a deb package, rather than using snaps.
I have it all set up in a virtual machine on my KVM, running with both a basic directory based storage pool, and a zfs storage pool. I ha... |
In the end I tested out incus on a physical box, and did not experience this issue. I would recommend that if someone is using Incus with the goal of virtual machines rather than just containers, that one does this on a physical host.
| Incus - Setting migration.stateful for stateful snapshots |
1,431,619,835,000 |
My prelimanary actions:
setting up a ddns hostname with noip service (ok)
configured to automatically keep alive the association on my home router(ok)
installed a proxmox server v8 (ok)
create a lxc container with model "debian11-turnkey-wordpress" with a static IP (ok)
configured port forwarding 80,443 on router to ... |
The problem was a bad configuration of port 443 on the router. Problem solved.
| Obtain a Wordpress Website with a Proxmox container available from outside with https (ssl encryption) |
1,431,619,835,000 |
OS: Debian Buster 10.10 inside lxc
I am attempting to install a new package (I tried different packages) and apt (and DPkg) is complaining with the following error message(s):
/etc/etckeeper/pre-install.d/README: 1: /etc/etckeeper/pre-install.d/README: Files: not found
/etc/etckeeper/pre-install.d/README: 2: /etc/etck... |
edit: update with more information found from here. I renamed the following directories and recreated them:
/etc/etckeeper/
pre-install.d
post-install.d
unclean.d
And it allowed me to install new packages.
If you want to get rid of etckeeper all together:
rm -rf /var/lib/dpkg/info/etckeeper.*
rm -r... | How can I fix etckeeper or uninstall it so apt will install / remove new packages? |
1,431,619,835,000 |
Debian Buster amd64
Two containers, 192.168.122.2,3 both can resolve but cannot get to the Internet
Both containers can ping / interact with the host server.
Here is what I have in iptables.
# Generated by xtables-save v1.8.2 on Sat Mar 6 17:16:16 2021
*filter
:INPUT ACCEPT [47377:13690982]
:FORWARD ACCEPT ... |
I found the fix for it. https://discuss.linuxcontainers.org/t/internet-access-issue-inside-container/5258
I had to use iptables-legacy and do the following:
/sbin/iptables-legacy -t nat -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535
/sbin/iptables-legacy -t nat -... | lxc containers can ping host and can resolve dns internet addresses but cannot get to the internet |
1,431,619,835,000 |
I have a linux server, Debian buster with LXC configured for unprivileged containers.
I have also a lot of crash from sssd_be, dmesg from server said:
dmesg|grep segfault
sssd_be[6739]: segfault at 8 ip 00007f080b190714 sp 00007ffc24a170a8 error 4 in libdbus-1.so.3.19.7[7f080b15d000+52000]
sssd_be[7517]: segfault at ... |
I found a workaround.
Using ansible, and create a script which domain is running sssd_be
#!/bin/sh
pgrep -a sssd
cat /etc/hostname
I run the script with this "playbook" which show on stdout the result
- name: Transfer and execute a script.
hosts: all
become_user: root
tasks:
- script: script.sh
register: ... | Is possible to identify the LXC unprivileged container owner of process? |
1,431,619,835,000 |
I have some troubles with lxc unprivileged containers on Debian.
I follow this method:
a)I create the user unprivileged with home in /var/lxcunpriv
useradd -m -d /var/lxcunpriv lxcunpriv
b)I install the require packages
apt -y install lxc libvirt0 libpam-cgroup libpam-cgfs bridge-utils cgroupfs-mount
c)I change the ... |
Solution found
I edit rc.local
Instead of those lines
su - lxcunpriv <<EOF
sh workaround.sh
lxc-start -n myothercontainer
EOF
the correct lines are those
start() {
su - lxcunpriv <<EOF
/var/lxcunpriv/workaround.sh
lxc-start --name mycontainer
lxc-start --name myothercontainer
...
EOF
}
The container start.
The p... | Why this script works fine if run as user, but faili if run from rc.local? |
1,336,906,003,000 |
I would like to monitor one process's memory / cpu usage in real time. Similar to top but targeted at only one process, preferably with a history graph of some sort.
|
On Linux, top actually supports focusing on a single process, although it naturally doesn't have a history graph:
top -p PID
This is also available on Mac OS X with a different syntax:
top -pid PID
| How to monitor CPU/memory usage of a single process? |
1,336,906,003,000 |
How can I immediately detect when new files were added to a folder within a bash script?
I would like the script to process files as soon as they are created in the folder. Are there any methods aside from scheduling a cron job that checks for new files each minute or so?
|
You should consider using inotifywait, as an example:
inotifywait -m /path -e create -e moved_to |
while read dir action file; do
echo "The file '$file' appeared in directory '$dir' via '$action'"
# do something with the file
done
In Ubuntu, inotifywait is provided by the inotify-tools package... | Tool to monitor folder for new files and run command whenever new file is detected |
1,336,906,003,000 |
I have a growing log file for which I want to display only the last 15 lines. Here is what I know I can do:
tail -n 15 -F mylogfile.txt
As the log file is filled, tail appends the last lines to the display.
I am looking for a solution that only displays the last 15 lines and get rid of the lines before the last 15 af... |
It might suffice to use watch:
$ watch tail -n 15 mylogfile.txt
| How to monitor only the last n lines of a log file? |
1,336,906,003,000 |
For debugging purposes I want to monitor the http requests on a network interface.
Using a naive tcpdump command line I get too much low-level information and the information I need is not very clearly represented.
Dumping the traffic via tcpdump to a file and then using wireshark has the disadvantage that it is not ... |
Try tcpflow:
tcpflow -p -c -i eth0 port 80 | grep -oE '(GET|POST|HEAD) .* HTTP/1.[01]|Host: .*'
Output is like this:
GET /search?q=stack+exchange&btnI=I%27m+Feeling+Lucky HTTP/1.1
Host: www.google.com
You can obviously add additional HTTP methods to the grep statement, and use sed to combine the two lines into a ful... | On-the-fly monitoring HTTP requests on a network interface? |
1,336,906,003,000 |
I'm looking to list all ports a PID is currently listening on.
How would you recommend I get this kind of data about a process?
|
You can use ss from the iproute2 package (which is similar to netstat):
ss -l -p -n | grep "pid=1234,"
or (for older iproute2 version):
ss -l -p -n | grep ",1234,"
Replace 1234 with the PID of the program.
| List ports a process PID is listening on (preferably using iproute2 tools)? |
1,336,906,003,000 |
time is a brilliant command if you want to figure out how much CPU time a given command takes.
I am looking for something similar that can list the files being accessed by a program and its children. Either in real time or as a report afterwards.
Currently I use:
#!/bin/bash
strace -ff -e trace=file "$@" 2>&1 | perl ... |
I gave up and coded my own tool. To quote from its docs:
SYNOPSIS
tracefile [-adefnu] command
tracefile [-adefnu] -p pid
OPTIONS
-a List all files
-d List only dirs
-e List only existing files
-f List only files
-n List only non-existing files
-p pid ... | List the files accessed by a program |
1,336,906,003,000 |
I'm getting a lot of mail in my root user's mail account. This appears to be mostly reports and errors from things like cron scripts. I'm trying to work though and solve these things, possibly even have them be piped to some sort of "dashboard" - but until then how can I have these messages go to my personal e-mail ac... |
Any user, including root, can forward their local email by putting the forwarding address in a file called ~/.forward. You can have multiple addresses there, all on one line and separated by comma. If you want both local delivery and forwarding, put root@localhost as one of the addresses.
The system administrator can ... | Can I change root's email address or forward it to an external address? |
1,336,906,003,000 |
Given file path, how can I determine which process creates it (and/or reads/writes to it)?
|
The lsof command (already mentioned in several answers) will tell you what process has a file open at the time you run it. lsof is available for just about every unix variant.
lsof /path/to/file
lsof won't tell you about file that were opened two microseconds ago and closed one microsecond ago. If you need to watch a... | How to determine which process is creating a file? [duplicate] |
1,336,906,003,000 |
$ tail -f testfile
the command is supposed to show the latest entries in the specified file, in real-time right? But that's not happening. Please correct me, if what I intend it to do is wrong...
I created a new file "aaa" and added a line of text and closed it. then issued this command (first line):
$ tail -f aaa
xx... |
From the tail(1) man page:
With --follow (-f), tail defaults to following the file descriptor,
which means that even if a tail’ed file is renamed, tail will continue
to track its end. This default behavior is not desirable when you
really want to track the actual name of the file, not the file ... | How does the "tail" command's "-f" parameter work? |
1,336,906,003,000 |
I'd like to do a health check of a service by calling a specific url on it. Feels like the simplest solution would be to use cron to do the check every minute or so. In case of errors, cron sends me an email.
I tried using cUrl for this but I can't get it to output messages only on errors. If I try to direct output t... |
What about -sSf? From the man pages:
-s/--silent
Silent or quiet mode. Do not show progress meter or error messages.
Makes Curl mute.
-S/--show-error
When used with -s it makes curl show an error message if it fails.
-f/--fail
(HTTP) Fail silently (no output at all) on server errors. Th... | Health check of web page using curl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.