Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ceremcem/d093287564b3729f6bfc61c5006ee0aa to your computer and use it in GitHub Desktop.

Select an option

Save ceremcem/d093287564b3729f6bfc61c5006ee0aa to your computer and use it in GitHub Desktop.

Revisions

  1. ceremcem renamed this gist Dec 18, 2021. 1 changed file with 23 additions and 24 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,17 @@
    ## Install Ubuntu containers on Archlinux using LXC
    ## Install Debian containers on Archlinux using LXC

    Install the _lxc_ and the _debootstrap_ packages:
    ```
    # pacman -Sy lxc debootstrap
    ```

    ### Install an Ubuntu container
    ### Install an Debian container

    I will install Ubuntu 16. Therfore, I will use the _xenial_ release.
    If you want to install Ubuntu 12.04 LTS, use the _precise_ release.
    I will install Debian Buster.

    I create an LXC container named _ubuntu-16_ with the release _xenial_ and the architecture _amd64_:
    I create an LXC container named _mydebian_ with the release _buster_ and the architecture _amd64_:
    ```
    # lxc-create --name=ubuntu-16 --template=download -- --dist ubuntu --release xenial --arch amd64
    # lxc-create --name=mydebian --template=download -- --dist debian --release buster --arch amd64
    ```
    ### Setup the network

    @@ -44,7 +43,7 @@ Print the virtual network configuration _default_ provided by _libvirtd_.
    </network>
    ```

    Edit the file /var/lib/lxc/ubuntu-16/config to set-up the network configuration of the container:
    Edit the file /var/lib/lxc/mydebian/config to set-up the network configuration of the container:
    ```
    lxc.net.0.type = veth
    lxc.net.0.flags = up
    @@ -56,37 +55,37 @@ Setup the _virb0_ interface:
    ```
    # virsh net-start default
    ```
    ### Set-up the ubuntu password
    ### Set-up the `debian` password

    ```
    sudo lxc-attach -n ubuntu-16
    # passwd ubuntu
    sudo lxc-attach -n mydebian
    # passwd debian
    ```
    Type ctrl-d to detach to the session.

    ### Install openssh-server

    ```
    sudo lxc-start -F -n ubuntu-16
    sudo lxc-start -F -n mydebian
    ```
    Connect as `ubuntu` and install openssh-server as follow:
    Connect as `debian` and install openssh-server as follow:
    ```
    sudo apt install openssh-server
    ```

    ### Start the Ubuntu container
    ### Start the Debian container

    Start the Ubuntu container as follow:
    Start the Debian container as follow:
    ```
    # lxc-start --name ubuntu-16
    # lxc-start --name mydebian
    ```
    Get the IP of the Ubuntu container:
    Get the IP of the Debian container:
    ```
    # lxc-ls -f ubuntu-16 -F IPV4
    # lxc-ls -f mydebian -F IPV4
    ```
    You can stop the Ubuntu container as follow:
    You can stop the Debian container as follow:
    ```
    # lxc-stop --name ubuntu-16
    # lxc-stop --name mydebian
    ```

    ### Set a static IP for the container
    @@ -120,19 +119,19 @@ Restart the _libvirtd_ daemon:

    Stop the the _xenial_ container:
    ```
    # lxc-stop --name ubuntu-16
    # lxc-stop --name mydebian
    ```

    Add the following line in the file /var/lib/lxc/ubuntu-16/config:
    Add the following line in the file /var/lib/lxc/mydebian/config:
    ```
    lxc.net.0.ipv4.address = 192.168.122.2/24
    ```

    Restart the _ubuntu-16_ container.
    Restart the _mydebian_ container.

    ### Connect to the container
    ```
    # ssh ubuntu@192.168.122.2
    # ssh debian@192.168.122.2
    ```

    Use the password _ubuntu_ to connect.
    Use the password _debian_ to connect.
  2. @manoj23 manoj23 revised this gist Apr 17, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -62,9 +62,9 @@ Setup the _virb0_ interface:
    sudo lxc-attach -n ubuntu-16
    # passwd ubuntu
    ```
    Type ctrl-d to detach to the session
    Type ctrl-d to detach to the session.

    ### Instal openssh-server
    ### Install openssh-server

    ```
    sudo lxc-start -F -n ubuntu-16
  3. @manoj23 manoj23 revised this gist Apr 17, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ Install the _lxc_ and the _debootstrap_ packages:

    ### Install an Ubuntu container

    I will install Ubuntu 14.04 LTS. Therfore, I will use the _trusty_ release.
    I will install Ubuntu 16. Therfore, I will use the _xenial_ release.
    If you want to install Ubuntu 12.04 LTS, use the _precise_ release.

    I create an LXC container named _ubuntu-16_ with the release _xenial_ and the architecture _amd64_:
  4. @manoj23 manoj23 revised this gist Apr 17, 2019. 1 changed file with 27 additions and 10 deletions.
    37 changes: 27 additions & 10 deletions ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -10,9 +10,9 @@ Install the _lxc_ and the _debootstrap_ packages:
    I will install Ubuntu 14.04 LTS. Therfore, I will use the _trusty_ release.
    If you want to install Ubuntu 12.04 LTS, use the _precise_ release.

    I create an LXC container named _ubuntu-14_ with the release _trusty_ and the architecture _amd64_:
    I create an LXC container named _ubuntu-16_ with the release _xenial_ and the architecture _amd64_:
    ```
    # lxc-create --name=ubuntu-14 --template=ubuntu -- --release trusty --arch amd64
    # lxc-create --name=ubuntu-16 --template=download -- --dist ubuntu --release xenial --arch amd64
    ```
    ### Setup the network

    @@ -44,7 +44,7 @@ Print the virtual network configuration _default_ provided by _libvirtd_.
    </network>
    ```

    Edit the file /var/lib/lxc/ubuntu-14/config to set-up the network configuration of the container:
    Edit the file /var/lib/lxc/ubuntu-16/config to set-up the network configuration of the container:
    ```
    lxc.net.0.type = veth
    lxc.net.0.flags = up
    @@ -56,20 +56,37 @@ Setup the _virb0_ interface:
    ```
    # virsh net-start default
    ```
    ### Set-up the ubuntu password

    ```
    sudo lxc-attach -n ubuntu-16
    # passwd ubuntu
    ```
    Type ctrl-d to detach to the session

    ### Instal openssh-server

    ```
    sudo lxc-start -F -n ubuntu-16
    ```
    Connect as `ubuntu` and install openssh-server as follow:
    ```
    sudo apt install openssh-server
    ```

    ### Start the Ubuntu container

    Start the Ubuntu container as follow:
    ```
    # lxc-start --name ubuntu-14
    # lxc-start --name ubuntu-16
    ```
    Get the IP of the Ubuntu container:
    ```
    # lxc-ls -f ubuntu-14 -F IPV4
    # lxc-ls -f ubuntu-16 -F IPV4
    ```
    You can stop the Ubuntu container as follow:
    ```
    # lxc-stop --name ubuntu-14
    # lxc-stop --name ubuntu-16
    ```

    ### Set a static IP for the container
    @@ -101,17 +118,17 @@ Restart the _libvirtd_ daemon:
    # systemctl restart libvirtd
    ```

    Stop the the _trusty_ container:
    Stop the the _xenial_ container:
    ```
    # lxc-stop --name ubuntu-14
    # lxc-stop --name ubuntu-16
    ```

    Add the following line in the file /var/lib/lxc/ubuntu-14/config:
    Add the following line in the file /var/lib/lxc/ubuntu-16/config:
    ```
    lxc.net.0.ipv4.address = 192.168.122.2/24
    ```

    Restart the _ubuntu-14_ container.
    Restart the _ubuntu-16_ container.

    ### Connect to the container
    ```
  5. @manoj23 manoj23 revised this gist Dec 28, 2017. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -46,10 +46,10 @@ Print the virtual network configuration _default_ provided by _libvirtd_.

    Edit the file /var/lib/lxc/ubuntu-14/config to set-up the network configuration of the container:
    ```
    lxc.network.type = veth
    lxc.network.flags = up
    lxc.network.name = eth0
    lxc.network.link = virbr0
    lxc.net.0.type = veth
    lxc.net.0.flags = up
    lxc.net.0.name = eth0
    lxc.net.0.link = virbr0
    ```

    Setup the _virb0_ interface:
    @@ -108,7 +108,7 @@ Stop the the _trusty_ container:

    Add the following line in the file /var/lib/lxc/ubuntu-14/config:
    ```
    lxc.network.ipv4 = 192.168.122.2/24
    lxc.net.0.ipv4.address = 192.168.122.2/24
    ```

    Restart the _ubuntu-14_ container.
  6. @manoj23 manoj23 revised this gist Jun 26, 2016. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -10,9 +10,9 @@ Install the _lxc_ and the _debootstrap_ packages:
    I will install Ubuntu 14.04 LTS. Therfore, I will use the _trusty_ release.
    If you want to install Ubuntu 12.04 LTS, use the _precise_ release.

    I create an LXC container named _trusty_ with the release _trusty_:
    I create an LXC container named _ubuntu-14_ with the release _trusty_ and the architecture _amd64_:
    ```
    # lxc-create --name=trusty --template=ubuntu -- --dist ubuntu --release trusty --arch amd64
    # lxc-create --name=ubuntu-14 --template=ubuntu -- --release trusty --arch amd64
    ```
    ### Setup the network

    @@ -44,7 +44,7 @@ Print the virtual network configuration _default_ provided by _libvirtd_.
    </network>
    ```

    Edit the file /var/lib/lxc/trusty/config to set-up the network configuration of the container:
    Edit the file /var/lib/lxc/ubuntu-14/config to set-up the network configuration of the container:
    ```
    lxc.network.type = veth
    lxc.network.flags = up
    @@ -61,15 +61,15 @@ Setup the _virb0_ interface:

    Start the Ubuntu container as follow:
    ```
    # lxc-start --name trusty
    # lxc-start --name ubuntu-14
    ```
    Get the IP of the Ubuntu container:
    ```
    # lxc-ls -f trusty -F IPV4
    # lxc-ls -f ubuntu-14 -F IPV4
    ```
    You can stop the Ubuntu container as follow:
    ```
    # lxc-stop --name trusty
    # lxc-stop --name ubuntu-14
    ```

    ### Set a static IP for the container
    @@ -103,15 +103,15 @@ Restart the _libvirtd_ daemon:

    Stop the the _trusty_ container:
    ```
    # lxc-stop --name trusty
    # lxc-stop --name ubuntu-14
    ```

    Add the following line in the file /var/lib/lxc/trusty/config:
    Add the following line in the file /var/lib/lxc/ubuntu-14/config:
    ```
    lxc.network.ipv4 = 192.168.122.2/24
    ```

    Restart the _trusty_ container.
    Restart the _ubuntu-14_ container.

    ### Connect to the container
    ```
  7. @manoj23 manoj23 revised this gist Jun 26, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -108,7 +108,7 @@ Stop the the _trusty_ container:

    Add the following line in the file /var/lib/lxc/trusty/config:
    ```
    lxc.network.ipv4 = 192.168.122.2
    lxc.network.ipv4 = 192.168.122.2/24
    ```

    Restart the _trusty_ container.
  8. @manoj23 manoj23 revised this gist Apr 17, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ I create an LXC container named _trusty_ with the release _trusty_:
    ### Setup the network

    Install the _libvirt_ package because we need the _virsh_ program.
    Also, we will need _ebtables_ and _dnsmasq_ for the default NAT/DHCP networking. [1](https://wiki.archlinux.org/index.php/libvirt#Server)
    Also, we will need _ebtables_ and _dnsmasq_ for the default NAT/DHCP networking. [(*)](https://wiki.archlinux.org/index.php/libvirt#Server)
    ```
    # pacman -Sy libvirt ebtables dnsmasq
    ```
  9. @manoj23 manoj23 revised this gist Apr 17, 2016. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,9 @@ I create an LXC container named _trusty_ with the release _trusty_:
    ### Setup the network

    Install the _libvirt_ package because we need the _virsh_ program.
    Also, we will need _ebtables_ and _dnsmasq_ for the default NAT/DHCP networking. [1](https://wiki.archlinux.org/index.php/libvirt#Server)
    ```
    # pacman -Sy libvirt
    # pacman -Sy libvirt ebtables dnsmasq
    ```
    Start and enable the _libvirtd_ daemon.
    ```
    @@ -117,4 +118,4 @@ Restart the _trusty_ container.
    # ssh ubuntu@192.168.122.2
    ```

    The password is _ubuntu_.
    Use the password _ubuntu_ to connect.
  10. @manoj23 manoj23 revised this gist Apr 17, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -76,7 +76,7 @@ You can stop the Ubuntu container as follow:
    Edit the default virtual network provided by _libvirtd_ to restrict the DHCP range
    from 192.168.122.2-192.168.122.254 to 192.168.122.10-192.122.254.

    ```bash
    ```
    # virsh net-edit default
    ```
    as follow:
  11. @manoj23 manoj23 created this gist Apr 17, 2016.
    120 changes: 120 additions & 0 deletions ubuntu-on-archlinux-using-lxc.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,120 @@
    ## Install Ubuntu containers on Archlinux using LXC

    Install the _lxc_ and the _debootstrap_ packages:
    ```
    # pacman -Sy lxc debootstrap
    ```

    ### Install an Ubuntu container

    I will install Ubuntu 14.04 LTS. Therfore, I will use the _trusty_ release.
    If you want to install Ubuntu 12.04 LTS, use the _precise_ release.

    I create an LXC container named _trusty_ with the release _trusty_:
    ```
    # lxc-create --name=trusty --template=ubuntu -- --dist ubuntu --release trusty --arch amd64
    ```
    ### Setup the network

    Install the _libvirt_ package because we need the _virsh_ program.
    ```
    # pacman -Sy libvirt
    ```
    Start and enable the _libvirtd_ daemon.
    ```
    # systemctl start libvirtd
    # systemctl enable libvirtd
    ```

    Print the virtual network configuration _default_ provided by _libvirtd_.
    ```xml
    # virsh net-dumpxml default
    <network>
    <name>default</name>
    <uuid>f9f9128b-8183-4c2c-af56-23cd52100d3a</uuid>
    <forward mode='nat'/>
    <bridge name='virbr0' stp='on' delay='0'/>
    <mac address='52:54:00:8d:ea:7f'/>
    <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
    <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
    </ip>
    </network>
    ```

    Edit the file /var/lib/lxc/trusty/config to set-up the network configuration of the container:
    ```
    lxc.network.type = veth
    lxc.network.flags = up
    lxc.network.name = eth0
    lxc.network.link = virbr0
    ```

    Setup the _virb0_ interface:
    ```
    # virsh net-start default
    ```

    ### Start the Ubuntu container

    Start the Ubuntu container as follow:
    ```
    # lxc-start --name trusty
    ```
    Get the IP of the Ubuntu container:
    ```
    # lxc-ls -f trusty -F IPV4
    ```
    You can stop the Ubuntu container as follow:
    ```
    # lxc-stop --name trusty
    ```

    ### Set a static IP for the container

    Edit the default virtual network provided by _libvirtd_ to restrict the DHCP range
    from 192.168.122.2-192.168.122.254 to 192.168.122.10-192.122.254.

    ```bash
    # virsh net-edit default
    ```
    as follow:
    ```xml
    <network>
    <name>default</name>
    <uuid>bd881c3e-406f-40bb-84ed-b09e68f210e2</uuid>
    <forward mode='nat'/>
    <bridge name='virbr0' stp='on' delay='0'/>
    <mac address='52:54:00:2d:23:30'/>
    <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
    <range start='192.168.122.10' end='192.168.122.254'/>
    </dhcp>
    </ip>
    </network>
    ```

    Restart the _libvirtd_ daemon:
    ```
    # systemctl restart libvirtd
    ```

    Stop the the _trusty_ container:
    ```
    # lxc-stop --name trusty
    ```

    Add the following line in the file /var/lib/lxc/trusty/config:
    ```
    lxc.network.ipv4 = 192.168.122.2
    ```

    Restart the _trusty_ container.

    ### Connect to the container
    ```
    # ssh ubuntu@192.168.122.2
    ```

    The password is _ubuntu_.