fmadio / public

fmadio issue tracking
MIT License
8 stars 3 forks source link

Gen2 container update #314

Closed fmadio closed 5 years ago

fmadio commented 5 years ago
=> x86_64 arch is not there in the lxc container list, instead we have to create amd64. (Can list all the available arch by "sudo lxc-create -t download -n <name>)
=> Container will be created at "/mnt/store0/lxc/lib/lxc/", config and rootfs both.
=> Required binaries/scripts for creating container I kept at "/mnt/store0/ROOT" (debootstrap, wget https support (compiled busybox and created softlink), gpgv, container_mngr_lxc.sh, sha256sum, rsync trick to ignore ACL support request command "-A")
=> Exported PATH from /mnt/store0/etc/fmadio.rc
export PATH=/mnt/store0/ROOT/usr/bin:/mnt/store0/ROOT/usr/sbin:$PATH

=> Here is the script I wrote to manage the containers:

fmadio@fmadio20-162:~$ sudo /mnt/store0/ROOT/usr/sbin/container_mngr_lxc.sh
Usage: sudo /mnt/store0/ROOT/usr/sbin/container_mngr_lxc.sh <list | create | destroy | init | stopall | stop>
        list           To list the containers
        init           To initialize / start all containers
        stopall        To stop all the containers
        create <name>  To create new container based on ubuntu/bionic/amd64 with named specified
        stop <name>    To stop the specific container
        destroy <name> To destroy the specific container
fmadio@fmadio20-162:~$
fmadio@fmadio20-162:~$ sudo /mnt/store0/ROOT/usr/sbin/container_mngr_lxc.sh list
NAME          STATE   AUTOSTART GROUPS IPV4 IPV6
ubuntu100     STOPPED 0         -      -    -
ubuntu101     STOPPED 0         -      -    -
ubuntu_test_1 STOPPED 0         -      -    -
fmadio@fmadio20-162:~$ sudo /mnt/store0/ROOT/usr/sbin/container_mngr_lxc.sh init
Starting ubuntu100 container ...
Starting ubuntu101 container ...
Starting ubuntu_test_1 container ...
fmadio@fmadio20-162:~$
fmadio@fmadio20-162:~$ sudo /mnt/store0/ROOT/usr/sbin/container_mngr_lxc.sh list
NAME          STATE   AUTOSTART GROUPS IPV4          IPV6
ubuntu100     RUNNING 0         -      192.168.1.128 -
ubuntu101     RUNNING 0         -      192.168.1.139 -
ubuntu_test_1 RUNNING 0         -      192.168.1.113 -
fmadio@fmadio20-162:~$

fmadio@fmadio20-162:~$ sudo /mnt/store0/ROOT/usr/sbin/container_mngr_lxc.sh destroy ubuntu101
Destroyed container ubuntu101
fmadio@fmadio20-162:~$
fmadio@fmadio20-162:~$ sudo /mnt/store0/ROOT/usr/sbin/container_mngr_lxc.sh list
NAME          STATE   AUTOSTART GROUPS IPV4          IPV6
ubuntu100     RUNNING 0         -      192.168.1.128 -
ubuntu_test_1 RUNNING 0         -      192.168.1.113 -
fmadio@fmadio20-162:~$

fmadio@fmadio20-162:~$ sudo /mnt/store0/ROOT/usr/sbin/container_mngr_lxc.sh create ubuntu102
Creating new container ubuntu102
Checking cache download in /opt/fmadio/lxc/cache/lxc/bionic/rootfs-amd64 ...
Copy /opt/fmadio/lxc/cache/lxc/bionic/rootfs-amd64 to /opt/fmadio/lxc/lib/lxc/ubuntu102/rootfs ...
Copying rootfs to /opt/fmadio/lxc/lib/lxc/ubuntu102/rootfs ...
Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
Creating SSH2 RSA key; this may take some time ...
2048 SHA256:WHKiJiy8Bfrc3SF7oNpXzH2H7koglQgV59ZjgWeTVX8 root@fmadio20-162 (RSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:1Sh8RCOQP21kBRgLC5nA7gVD8CZYoOQs2BasWjWNwvI root@fmadio20-162 (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:Zg2/jo12POwfVR477cnXWhjXJVQkzf+jPldPHEAIuU4 root@fmadio20-162 (ED25519)
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Timezone in container is not configured. Adjust it manually.

##
# The default user is 'ubuntu' with password 'ubuntu'!
# Use the 'sudo' command to run tasks as root in the container.
##

Container ubuntu102 created successfully !
Starting container ubuntu102 ...
NAME          STATE   AUTOSTART GROUPS IPV4          IPV6
ubuntu100     RUNNING 0         -      192.168.1.128 -
ubuntu102     RUNNING 0         -      192.168.1.149 -
ubuntu_test_1 RUNNING 0         -      192.168.1.113 -
fmadio@fmadio20-162:~$

fmadio@fmadio20-162:~$
fmadio@fmadio20-162:~$ sudo lxc-attach -n ubuntu102
root@ubuntu102:/# exit
exit
fmadio@fmadio20-162:~$
fmadio@fmadio20-162:~$
fmadio@fmadio20-162:~$ ssh ubuntu@192.168.1.149
The authenticity of host '192.168.1.149 (192.168.1.149)' can't be established.
ECDSA key fingerprint is 5d:71:95:93:40:85:80:ae:cd:70:fc:15:74:6e:fd:07.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.149' (ECDSA) to the list of known hosts.
ubuntu@192.168.1.149's password:
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.9.135-tinycore64 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ubuntu102:~$
ubuntu@ubuntu102:~$ uptime
 16:11:28 up 1 day,  2:07,  1 user,  load average: 0.25, 0.32, 0.24
ubuntu@ubuntu102:~$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
    link/ipip 0.0.0.0 brd 0.0.0.0
3: ip_vti0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
    link/ipip 0.0.0.0 brd 0.0.0.0
48: eth0@if49: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:40:d1:e0 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.1.149/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 215846sec preferred_lft 215846sec
    inet6 fe80::216:3eff:fe40:d1e0/64 scope link
       valid_lft forever preferred_lft forever
ubuntu@ubuntu102:~$
fmadio commented 5 years ago

systemd nonsense

Like this: mkdir -p /sys/fs/cgroup/systemd; mount -t cgroup -o none,name=systemd systemd /sys/fs/cgroup/systemd

fmadio commented 5 years ago

updated closing