mkdir /var/lib/vz/snippets cp /usr/share/pve-docs/examples/guest-example-hookscript.pl /var/lib/vz/snippets/hookscript.pl vim /var/lib/vz/snippets/hookscript.pl
在第36行可以找到以下内容
1 2 3 4
# Second phase 'post-start' will be executed after the guest # successfully started.
print"$vmid started successfully.\n";
修改为
1 2 3 4 5
# Second phase 'post-start' will be executed after the guest # successfully started. system("lxc-device add -n $vmid /dev/ppp"); system("lxc-device add -n $vmid /dev/net/tun"); print"$vmid started successfully.\n";
run_buffer: 316 Script exited with status 1 lxc_init: 816 Failed to run lxc.hook.pre-start for container "100" __lxc_start: 2007 Failed to initialize container "100" startup for container '100' failed
解决方法是修改/usr/share/perl5/PVE/LXC/Setup.pm文件
1
vim /usr/share/perl5/PVE/LXC/Setup.pm
翻到最后,可以看到以下内容
1 2 3 4 5 6
sub unified_cgroupv2_support { my ($self) = @_; $self->protected_call(sub { $self->{plugin}->unified_cgroupv2_support(); }); }
修改为
1 2 3 4 5 6 7
sub unified_cgroupv2_support { my ($self) = @_; returnif !$self->{plugin}; # unmanaged $self->protected_call(sub { $self->{plugin}->unified_cgroupv2_support(); }); }
继续执行pct start 100指令启动容器,会出现WARN: old systemd (< v232) detected, container won't run in a pure cgroupv2 environment! Please see documentation -> container -> cgroup version.警告,忽略就行。
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world b8dfde127a29: Pull complete Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e Status: Downloaded newer image for hello-world:latest
Hello from Docker! This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/
For more examples and ideas, visit: https://docs.docker.com/get-started/
# include the fastcgi_param setting include fastcgi_params;
# SCRIPT_FILENAME parameter is used for PHP FPM determining # the script name. If it is not set in fastcgi_params file, # i.e. /etc/nginx/fastcgi_params or in the parent contexts, # please comment off following line: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }