Category Archives: Virtualization

redirect input into dockerfile


docker build -t myimage:latest  -f- . <<EOF
FROM centos
CMD mkdir /app
WORKDIR /app
RUN echo "file contents" > file.txt
EOF

Sending build context to Docker daemon  16.43kB
Step 1/4 : FROM centos
 ---> 470671670cac
Step 2/4 : CMD mkdir /app
 ---> Using cache
 ---> cf9be82aca00
Step 3/4 : WORKDIR /app
 ---> Using cache
 ---> 24baea1f7712
Step 4/4 : RUN echo "file contents" > file.txt
 ---> Using cache
 ---> 61db761dc411
Successfully built 61db761dc411
Successfully tagged myimage:latest

docker run --name ttt -ti -d --privileged=true myimage  "/sbin/init"
docker exec -it ttt cat '/app/file.txt'
file contents


‘utf-8’ codec can’t decode byte 0xf0 in position 0: invalid continuation byte virt-install


Error: --disk path=/var/lib/libvirt/images/centos7.qcow2,size=15,device=disk,bus=virtio,format=qcow2: 'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte

sudo virt-install --connect=qemu:///system --network=bridge:virbr0 --extra-args="ks=http://192.168.0.101:1111/centos7.cfg console=tty0 console=ttyS0,115200" --name=aaa --disk path=/var/lib/libvirt/images/centos7.qcow2,size=15,device=disk,bus=virtio,format=qcow2 --ram 1500 --vcpus=1 --check-cpu --accelerate --hvm --location=http://mirror.cherryservers.com/centos/7/os/x86_64/ --nographics

virsh # pool-list

Name State Autostart
------------------------------------
boot-scratch active yes
images active yes
tmp active yes
virtio-win active yes
vit active yes

virsh # pool-destroy vit
Pool vit destroyed

virsh # pool-destroy virtio-win
Pool virtio-win destroyed

'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte error was because of virStorageVolGetName:

File "/usr/lib64/python3.7/site-packages/libvirt.py", line 3650, in name
ret = libvirtmod.virStorageVolGetName(self._o)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf0 in position 0: invalid continuation byte
[Mon, 17 Feb 2020 15:26:54 virt-install 57908] DEBUG (cli:263) File "/usr/share/virt-manager/virt-install", line 1005, in

virt-install should be working now again

error: unpacking of archive failed on file /usr/sbin/suexec;5e440e82: cpio: cap_set_file

Running transaction
Installing : httpd-2.4.6-90.el7.centos.x86_64 1/1
Error unpacking rpm package httpd-2.4.6-90.el7.centos.x86_64
error: unpacking of archive failed on file /usr/sbin/suexec;5e440e82: cpio: cap_set_file
Verifying : httpd-2.4.6-90.el7.centos.x86_64 1/1

Failed:
httpd.x86_64 0:2.4.6-90.el7.centos

/var/lib/lxc/new.server.lt/config
lxc.cap.drop =
lxc.cap.drop = mac_admin mac_override setpcap
lxc.cap.drop = sys_module sys_nice sys_pacct
lxc.cap.drop = sys_rawio sys_time

echo “%_netsharedpath /sys:/proc” >> /etc/rpm/macros.dist

Transaction test succeeded
Running transaction
Installing : httpd-2.4.6-90.el7.centos.x86_64

Restarting network (via systemctl): Job for network.service canceled

service network restart
Restarting network (via systemctl): Job for network.service canceled.
[FAILED]

systemctl restart network
Job for network.service canceled.

If cyberpanel server network is down (venet0: mtu 1500 qdisc noop state DOWN) after server reboot, make sure:

vi /etc/fstab
#/usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0
#/tmp /var/tmp none bind 0 0

service network restart
Restarting network (via systemctl):
[ OK ]

Too many open files in system openvz

id: cannot find name for user ID 0
-bash: cannot make pipe for command substitution: Too many open files in system
-bash: /etc/profile.d/less.sh: Too many open files in system
-bash: /etc/profile.d/mc.sh: Too many open files in system
-bash: /etc/profile.d/vim.sh: Too many open files in system
-bash: /etc/profile.d/which-2.sh: Too many open files in system
-bash: /root/.bash_profile: Too many open files in system
-bash-3.2# logout
-bash: /root/.bash_logout: Too many open files in system
-bash: /etc/bash.bash_logout: Too many open files in system
exited from CT XXXX

Fast fix:
vzctl restart XXXX

kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=255)

ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=255)

journalctl -u kubelet
kubelet[25843]: F0310 21:08:58.395379 25843 server.go:189] failed to load Kubelet config file /var/lib/kubelet/config.yaml, error
kubelet.service: main process exited, code=exited, status=255/n/a

Fix:
kubeadm init

[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using ‘kubeadm config images pull’
[kubelet-start] Writing kubelet environment file with flags to file “/var/lib/kubelet/kubeadm-flags.env”
[kubelet-start] Writing kubelet configuration to file “/var/lib/kubelet/config.yaml”
[kubelet-start] Activating the kubelet service
[certs] Using certificateDir folder “/etc/kubernetes/pki”
[certs] Generating “etcd/ca” certificate and key
[certs] Generating “etcd/server” certificate and key