Installing Docker.io on Ubuntu 14.04LTS - azure

I'm running a virtual machine in Windows Azure with the prebuild image for Ubuntu 14.04 LTS.
When I want to install Docker.io like described here:
http://blog.docker.io/2014/04/docker-in-ubuntu-ubuntu-in-docker/
The installation works but when i`m running:
sudo docker.io pull ubuntu
An error will be thrown:
Cannot connect to the Docker daemon. Is docker -d running on this host?
Can anyone help or has the similar problem?
P.S.: Can anyone with a high reputation create a Tag for Ubuntu-14.04?

Evidently the docker daemon is not running. You wanna check /etc/default/docker.conf for proper configuration and issue
sudo service docker.io start
or
sudo service docker start
depending on how they called the service

Adding myself to the docker group:
sudo usermod -a -G docker myuser
and rebooting the machine worked for me. This solution is discussed in: https://github.com/docker/docker/issues/5314

On Ubuntu 14.04, the docker.io package installs Docker 0.9.1.
According to the documentation, to install the current version use these commands:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update
$ sudo apt-get install lxc-docker
There is also a simple script available to help with this process:
$ curl -s https://get.docker.io/ubuntu/ | sudo sh
Alternatively, check the azure-docker-registry project for an example of how to automate Azure provisioning and Docker container deployment. For instance, this Ansible playbook:
- name: create docker data directory
file: path=/mnt/data/docker state=directory
- name: store docker files in data disk
file: src=/mnt/data/docker dest=/var/lib/docker state=link
- name: add repository key
command: creates=/etc/apt/sources.list.d/docker.list apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
- name: copy repository source file
copy: src=docker.list dest=/etc/apt/sources.list.d/docker.list
- name: install docker package
apt: name=lxc-docker update_cache=yes state=present

Also make sure to symlink the docker.io binary to docker to use the tutorials/documentation without rewriting every command.
ln -s /usr/bin/docker.io /usr/bin/docker

Run docker -d to see if it shows any error messages.
If apparmor is missing install it with sudo apt-get install apparmor
Then sudo service docker start

Hard to say but sometime official docker installation procedure fails on Ubuntu 14.04.
One can simply install docker using below given commands [Quick and Dirty]
sudo apt-get update
sudo apt-get -y install docker.io

Related

Steps to install docker daemon on Linux VM

Goal:
We are creating dev environments for developers in GCP cloud.
Every developer would have a dedicated Linux VM in GCP for day to day development tasks & testing
Linux VM is a dev environment(with multiple tools installed for source code checkout etc...). Docker daemon is another tool, needed, for day to day tasks.
So, Linux VM should have docker daemon(installed) to launch docker containers(for testing).
Can we install docker daemon on Linux VM? if yes, please provide steps..
When I build VMs for developers that require Docker, I use a startup script so that Docker is installed when the VM is created. This script can also be used in a terminal window to manually install Docker.
This script is for Debian/Ubuntu systems.
One variable is required. $USER needs to be added to the docker group so that users can run containers without sudo permissions. This script runs commands with sudo which is not required as a startup script but is required for a normal user.
#!/bin/bash -v
sudo apt update
sudo apt upgrade -y
sudo apt install apt-transport-https -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce -y
sudo usermod -aG docker ${USER}
echo "User ${USER} added to docker group. Re-login to assume docker group membership."
You can refer the document provided by digital ocean.
I was able to successfully setup docker using the above and once docker is installed, make sure to add your user into docker group. Please refer this link for post installation tasks.

Installing docker-compose on Amazon EC2 Linux 2. 9kb docker-compose file

First of all, let me state I'm not the most virtuous of Linux users, so bear with me...
Below is a brief run-down of all the steps I took. Ultimately the question/issue is is that it seems impossible for me to get a proper docker-compose installation downloaded.
Followed instructions to install docker https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Tried 4 variations of the above command to try to install docker-compose. As shown in the URLs below.
https://www.codegrepper.com/code-examples/php/how+to+install+docker+compose+in+ec2
https://portal.cloud303.io/forum/aws-1/question/i-want-to-install-docker-compose-on-an-amazon-linux-2-ec2-instance-9
https://acloudxpert.com/how-to-install-docker-compose-on-amazon
https://gist.github.com/npearce/6f3c7826c7499587f00957fee62f8ee9
When typing "docker-compose", "sudo docker-compose" etc. All it will say is
"Line 1: Not: command not found".
It seems to be the issue that the docker-compose file is only 9kb in size. Because this is what I get back every time I use the above mentioned docker-compose install sequences.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 9 100 9 0 0 58 0 --:--:-- --:--:-- --:--:-- 58
This issue is sort of addressed here:
https://github.com/docker/compose/issues/6268
Where it is said that the OS is not supported or that we're running a 32bit instance, but of which seem to be strange because all the above tutorials are specifically for AWS EC2 Linux 2.
fwiw 'uname -m' returns aarch64.
So, does anyone have an idea of how to get a full-sized version of docker-compose instead of the 9kb file?
Thanks!
followed the link to install the docker-compose link
Basically, thee are only two steps as below:
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
Amazon Linux is "just" the OS, but compiled binaries also depend on your processor architecture. For instance, EC2 t3a series are based on x86_64 architecture wheras the new t4g types are of aarch64 (which is the reason I run into as similar issue as you and ended up here). uname -m returns that identifier, in your case apparently aarch64.
Since the docker-compose github repo contains no released binary for this architeture (as opposed to x86_64), the resolved full download URL returns a "Not found" body instead of the expected binary, thus the described error message when you try to execute it.
As you already found out, there a multiple threads which discuss this issue. The only thing that eventually worked for me was to install docker-compose manually via python's packaga manager pip. Since this approach involves a couple of compilation steps, you need to add various additional OS packages and may face other mostly dependency related errors in the process. But the following steps eventually worked for me:
uname -s -m
1> Linux aarch64
cat /etc/system-release
1> Amazon Linux release 2 (Karoo)
sudo yum install -y python37 \
python3-devel.$(uname -m) libpython3.7-dev \
libffi-devel openssl-devel
# need gcc and friends
sudo yum groupinstall -y "Development Tools"
# make sure pip is up2date
sudo python3 -m pip install -U pip
python3 -m pip install docker-compose
docker-compose --version
1> docker-compose version 1.27.4, build unknown
Hope it works for you as well. Good Luck!
You can start from the scratch on Amazon Linux ec2 instance for installing Docker by following the step:
sudo yum update -y
sudo amazon-linux-extras install docker
sudo yum install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
Then logout from the instance and login again to verify the installation of Docker
docker info
To install Docker-compose follow the below steps:
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
I tried everything here mentioned, in the end, it was a problem with the symlink. The official docker page gave me the solution.
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
If it doesn't work after that command, check if you can find docker in your bin folder, e.g. with: ls /usr/local/bin/
If you can see docker-compose there, you almost made it.
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
An easy way to check if docker-compose is there and Linux able to find it, is to use `which docker-compose, also if it is linked correctly, you will get the path to docker-compose as a response.
This worked for me on a AWS EC2 instance with Linux2 as OS.
I faced the same issue. My configuration is T4Large - ARM64 - Ubuntu Server 20.04 LTS and I resolved using the following command
$ sudo apt install docker-compose
This will install the 1.25.0 version of docker compose which is a bit older. At the time of writing this answer the current version is 1.29.1
Another alternative is to use Docker Compose as Docker Container.
Use the following commands to run Docker Compose Container
$ sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
This should work on any Linux distro and on architecture like x86_64, armv7l/armhf, and aarch64/armv8/arm64 if you already have docker installed.
The important point to note is, this runs compose inside a container and does not require installing python on the host system.
Docker hub reference: https://hub.docker.com/r/linuxserver/docker-compose
Installing Docker-Compose in EC2 instance follow below steps
1st command: # sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
2nd command: # sudo chmod +x /usr/local/bin/docker-compose
3rd command: # ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
4th Command to verify docker compose: # docker-compose version
It will install latest version of docker-compose. 3rd command is necessary.
This will do everything you need.
Cut. paste. done.
cat ec2-al2-docker-compose.sh
#the following script will install docker and docker compose on amazon linux 2
# run this script then
# sudo docker ps; docker-compose up
# note docker-compose up doesnt use sudo
sudo yum update -y
sudo yum install docker git -y
sudo usermod -a -G docker ec2-user
id ec2-user
newgrp docker
sudo yum install python3-pip -y
sudo pip3 install docker-compose
sudo systemctl enable docker.service
sudo systemctl start docker.service

Install microk8s via snap using Ansible, on WSL 2

I'm trying to install microk8s, using Ansible.
I get the error : "No snap matching 'microk8s' available"
I'm using WSL 2 (Ubuntu 20.04), and snap version 2.44.3+20.04.
My configuration:
- name: Install microk8s
snap:
name:
- microk8s
classic: yes
become: true
Does anyone know how to fix this?
On the WSL terminal, what happens if you type: snap version.
It seems that snap is broken on WSL2 and using Ubuntu 20.04.
You could try to:
sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME
It could also be a network/firewall issue. What happens if you try to install other packages.

How ro run sudo su - in Dockerfile

I am trying to RUN sudo su - inside the Dockerfile and I get this error
/bin/sh: 1: sudo: not found
This is how my Dockerfile looks like:
FROM ubuntu:18.04
RUN sudo su -
RUN apt update && install openjdk-8-jdk
RUN wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add - && sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/kenkins.list'
RUN apt update && apt install jenkins
RUN curl -fsSL get.docker.com | /bin/bash
RUN usermod -aG docker jenkins && systemctl restart jenkins
This error comes when I try to build it.
docker build -t jenkins .
Can someone help me?
The dockerfile will run as a virtual "root" user by default, so there is no need to include any sudo command.
Since the example script contains no "-y" defaults it seems that you have simply typed the description for a manual installation into a script. This will never work. And well, in a container the application does also need to be on PID-1 which systemctl will not do.
After going through a basic tutorial on docker you will find out why.
This command seems not to be doing anything except for creating an extra layer without any useful effect.
$ cat Dockerfile
FROM ubuntu:18.04
RUN apt-get update && apt-get install openjdk-8-jdk -y
If You want to change the use privilege use USER flag in Dockerfile

Hyperledger Fabric 1.0 on CentOS Error endorsing chaincode?

I am running CentOS Linux release 7.2.1511 (Core).
Running the "first network" sample of the brand new Hyperledger Fabric 1.0 out yesterday I am getting the error:
Error: Error endorsing chaincode: rpc error: code = Unknown desc = Error starting container: API error (500): {"message":"oci runtime error: container_linux.go:262: starting container process caused \"process_linux.go:339: container init caused \\"read init-p: connection reset by peer\\"\"\n"}
How do I debug further?
My complete installation procedure of prereqs was as follows:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 policycoreutils-python git dos2unux unzip gcc-c++ make
sudo yum-config-manager --enable rhel-7-server-extras-rpms
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
wget http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm
yum -y install docker-ce
sudo yum -y install docker-ce
sudo systemctl start docker
sudo docker run hello-world
sudo usermod -aG docker root
sudo usermod -aG docker vagrant
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y ./epel-release-latest-7.noarch.rpm
sudo yum install -y python-pip
sudo pip install docker-compose
sudo yum upgrade python*
cd
mkdir docker-compose-hello-world
cd docker-compose-hello-world
echo 'my-test:' > ./docker-compose.yml
echo ' image: hello-world' >> ./docker-compose.yml
docker-compose up
sudo docker-compose up
cd
mkdir golang
cd golang
echo downloading go1.8.3.linux-amd64.tar.gz
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
sudo cp ./go1.8.3.linux-amd64.tar.gz /usr/local
cd /usr/local
sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
sudo vi /etc/profile
cd
sudo curl -sL https://rpm.nodesource.com/setup_6.x | sudo bash -
sudo yum install -y nodejs
sudo npm install npm#latest -g
cd
git clone https://github.com/hyperledger/fabric-samples.git
sudo docker run hello-world
sudo systemctl start docker
sudo docker run hello-world
cd fabric-samples
# Stackoverflow validation asked me to replace short URL
# goo.gl/iX9dek with long one below:
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap-1.0.0.sh | sudo bash
cd first-network
yes | sudo ./byfn.sh -m generate
yes | sudo ./byfn.sh -m up
My NodeJs (node) version is v6.11.1
My npm version is 5.2.0
My Golang version is go1.8.3 linux/amd64
Thanks in advance for any enlightenment!
Resolved!
Inspired by reference https://github.com/moby/moby/issues/34046, I upgraded the Linux kernel using the instructions at:
https://www.tecmint.com/install-upgrade-kernel-version-in-centos-7/
Works perfectly after a reboot and a selection of the new kernel in the boot menu.
Downside: the Vagrant shared folders between the Windows 7 host OS and the CentOS virtual machine no longer work, but that should be fixed by the next Oracle Virtualbox client tools update.

Resources