0% found this document useful (0 votes)
17 views12 pages

Docker Document (Docker+Yocto)

Docker is a software platform that enables quick building, testing, and deployment of applications through containers, which are more portable and resource-efficient than virtual machines. The document provides detailed installation instructions for Docker on Ubuntu 20.04 and 18.04, along with commands for managing Docker containers and images. Additionally, it outlines steps for setting up a Yocto project within a Docker container, including necessary package installations and configuration.

Uploaded by

201it022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views12 pages

Docker Document (Docker+Yocto)

Docker is a software platform that enables quick building, testing, and deployment of applications through containers, which are more portable and resource-efficient than virtual machines. The document provides detailed installation instructions for Docker on Ubuntu 20.04 and 18.04, along with commands for managing Docker containers and images. Additionally, it outlines steps for setting up a Yocto project within a Docker container, including necessary package installations and configuration.

Uploaded by

201it022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 12

lsDOCKER

What is Docker and why is it used?

• Docker is a software platform that allows you to build, test, and deploy applications quickly.
Docker packages software into standardized units called containers that have everything the
software needs to run including libraries, system tools, code, and runtime.
• Docker is an application that simplifies the process of managing application processes in
containers. Containers let you run your applications in resource-isolated processes. They’re
similar to virtual machines, but containers are more portable, more resource-friendly, and more
dependent on the host operating system.

INSTALLING AND EXECUTING DOCKER IN UBUNTU 20.04 AND UBUNTU 18.04

**************************************************************************

Step 1 — Installing Docker(Ubuntu 20.04.6 LTS)


➔ First, update your existing list of packages:
• sudo apt update
➔ Install a few prerequisite packages which let apt use packages over HTTPS:
• sudo apt install apt-transport-https ca-certificates curl software-properties-
common
➔ Then add the GPG key for the official Docker repository to your system:
• curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
➔ Add the Docker repository to APT sources:
• sudo add-apt-repository "deb [arch=amd64]
https://download.docker.com/linux/ubuntu focal stable"
➔ This will also update our package database with the Docker packages from the newly added repo.
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
• apt-cache policy docker-ce
Installed: (none)
Candidate: 5:19.03.9~3-0~ubuntu-focal
Version table:
5:19.03.9~3-0~ubuntu-focal 500
500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
➔ Finally, install Docker
• sudo apt install docker-ce
➔ Docker should now be installed, the daemon started, and the process enabled to start on boot.
Check that it’s running:
• sudo systemctl status docker utput
docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-05-19 17:00:41 UTC; 17s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 24321 (dockerd)
Tasks: 8
Memory: 46.4M
CGroup: /system.slice/docker.service
└─24321 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Step 2 — Executing the Docker Command Without


➔ If you want to avoid typing sudo whenever you run the docker command, add your username to
the docker group:
• sudo usermod -aG docker ${USER}
➔ To apply the new group membership, log out of the server and back in, or type the following:
• su - ${USER}
➔ Confirm that your user is now added to the docker group by typing:
• id -nG
➔ You will be prompted to enter your user’s password to continue. Confirm that your user is now
added to the docker group by typing:
• groupsOutput
phytec sudo docker

➔ If you need to add a user to the docker group that you’re not logged in as, declare that username
explicitly using:
• sudo usermod -aG docker username
********************************************************************************
Step 1 — Installing Docker(Ubuntu 18.04.6 LTS)
➔ First, update your existing list of packages:
• sudo apt update
➔ Install a few prerequisite packages which let apt use packages over HTTPS:
•sudo apt install apt-transport-https ca-certificates curl software-properties-
common
➔ Then add the GPG key for the official Docker repository to your system:
• curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
➔ Add the Docker repository to APT sources:
• sudo add-apt-repository "deb [arch=amd64]
https://download.docker.com/linux/ubuntu bionic stable"
➔ Next, update the package database with the Docker packages from the newly added repo:
• sudo apt update
➔ Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
• apt-cache policy docker-ce
docker-ce:
Installed: (none)
Candidate: 18.03.1~ce~3-0~ubuntu
Version table:
18.03.1~ce~3-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
➔ Finally, install Docker
• sudo apt install docker-ce
➔ Docker should now be installed, the daemon started, and the process enabled to start on boot.
Check that it’s running:
• sudo systemctl status docker● docker.service - Docker Application Container
Engine
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-08-09 19:42:32 UTC; 33s ago
Docs: https://docs.docker.com
Main PID: 5231 (dockerd)
Tasks: 7
CGroup: /system.slice/docker.service
└─5231 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Step 2 — Executing the Docker Command Without
➔ If you want to avoid typing sudo whenever you run the docker command, add your username to
the docker group:
• sudo usermod -aG docker ${USER}
➔ To apply the new group membership, log out of the server and back in, or type the following:
• su - ${USER}
➔ You will be prompted to enter your user’s password to continue. Confirm that your user is now
added to the docker group by typing:
• groupsOutput
phytec sudo docker

➔ If you need to add a user to the docker group that you’re not logged in as, declare that username
explicitly using:
sudo usermod -aG docker username

**************************************************************************

Step 3 — Using the Docker Command


➔ Using docker consists of passing it a chain of options and commands followed by arguments
• docker [option] [command] [arguments]
➔ To view all available subcommands, type:
• docker
➔ To view the options available to a specific command, type:
• docker docker-subcommand –help
➔ To view system-wide information about Docker, use:
• docker info

Step 4 — Working with Docker Images


➔ To check whether you can access and download images from Docker Hub, type:
• docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
Status: Downloaded newer image for hello-world:latest

Hello from Docker!


This message shows that your installation appears to be working correctly.

➔ Now we can search for images available on Docker Hub by using the docker command with the
search subcommand. For example, to search for the Ubuntu image, type:
• docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL
AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating sys… 10908 [OK]
dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interface … 428 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 244 [OK]
consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC session… 218 [OK]
ubuntu-upstart Upstart is an event-based replacement for th… 108 [OK]
ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with
...

➔ Execute the following command to download the official ubuntu image to your computer:
• docker pull ubuntu:16.04
Using default tag: latest
latest: Pulling from library/ubuntu
d51af753c3d3: Pull complete
fc878cd0a91c: Pull complete
6154df8ff988: Pull complete
fee5db0ff82f: Pull complete
Digest: sha256:747d2dbbaaee995098c9792d99bd333c6783ce56150d1b11e333bbceed5c54d7
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest

➔ To see the images that have been downloaded to your computer, type:
• docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 1d622ef86b13 3 weeks ago 73.9MB
hello-world latest bf756fb1ae65 4 months ago 13.3kB

Step 5 — Running a Docker Container


➔ Now run a container using the latest image of Ubuntu. The combination of the -i and -t switches gives
you interactive shell access into the container:
• docker run -it ubuntu:16.04
• Output root@6e73c5008118:

Step 6 — Managing Docker Containers


➔ To view the active ones, use:
• docker ps
➔ To view all containers — active and inactive, run docker ps with the -a switch:
• docker ps -a
➔ To view the latest container you created, pass it the -l switch:
• docker ps -l
➔ To start a stopped container, use docker start, followed by the container ID or the container’s name.
• docker start <CONTAINER ID>
➔ To stop a running container, use docker stop, followed by the container ID or name. This time, we’ll use
the name that Docker assigned the container.
• docker stop <NAMES>
➔ Once you’ve decided you no longer need a container anymore, remove it with the docker rm command,
again using either the container ID or the name. Use the docker ps -a command to find the container ID or
name for the container associated with the hello-world image and remove it.
• docker rm <NAMES>
STEPS NEED TO FOLLOW IN BOTH SERVER AND USER SIDE:
SERVER(LINUX PC):-(once to do)(Ubuntu 20.04.6 LTS)

1. Update your existing list of packages:


• sudo apt update
2. Install a few prerequisite packages which let apt use packages over HTTPS:
• sudo apt install apt-transport-https ca-certificates curl software-properties-common
3. Then add the GPG key for the official Docker repository to your system:
• curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4. Add the Docker repository to APT sources:
• sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal
stable"
5. Make sure you are about to install from the Docker repo instead of the default Ubuntu repo
• apt-cache policy docker-ce
6. Install Docker:
• sudo apt install docker-ce
7. Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s
running:
• sudo systemctl status docker

USER SIDE :
1. To view all available subcommands, type.
• docker
2. To view system-wide information about Docker, use.
• docker info
3. To search for images available on Docker Hub by using the docker command with the search subcommand. For
example, to search for the Ubuntu image, type.
• docker search ubuntu
4. Execute the following command to download the official ubuntu image to your computer.
• docker pull ubuntu(version)
5. To run a container using the latest image of Ubuntu. The combination of the -i and -t switches gives you
interactive shell access into the container.
• docker run -it ubuntu(version)
6. Add your username to the docker group with permission
• sudo usermod -aG docker ${USER}
7. To apply the new group membership, log out of the server and back in, or type the following, this requres users
password to contineu.
• su - ${USER}
CONTAINER SIDE:
1. Once we get the container ID, we can use the container using command
• docker start <container ID>
2. To attach with the container
• docker attach <container ID>
Building with Docker + Yocto(rba5d2x)
➔ To run the following code from host machine

➢ docker pull ubuntu:16.04

➢ docker run -it ubuntu:16.04

➔ To rename the docker name while running the host machine

➢ docker run –name <name> -it ubuntu<version>

e.g docker run –name yocto-rba5d27 -it ubuntu:16.04

➔ Now you will be in the docker container, should look like

➢ root@6e73c5008118:/#

➔ Install the packages needed for yocto

➢ apt-get update

➢ apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential
chrpath socat libsdl1.2-dev

➢ apt-get install curl

➢ apt-get install python3

➢ apt-get install vim

➢ apt-get install cpio

➢ apt-get install git

➢ apt-get install mtd-utils

➢ apt-get install locales

➢ dpkg-reconfigure locales

1) add this to vi ~/.bashrc

export LC_ALL=en_US.UTF-8

dockerexport LANG=en_US.UTF-8

export LANGUAGE=en_US.UTF-8

2) To compiles file for locale and C library

localedef -v -c -i en_US -f UTF-8 en_US.UTF-8

3) add this lines to /etc/environment (optional)

LC_ALL=en_US.UTF-8

LANG=en_US.UTF-8

4) Now run
source ~/.bashrc
still error*******
ans:- apt-get install language-pack-en-base

➔ Verify that the preferred shell for your Host PC is ''bash'' and not ''dash'':
➢ dpkg-reconfigure dash

➢ # Respond "No" to the prompt asking "Install dash as /bin/sh?"

BSP Directory Setup


Now set up git(optional:for dockerhub)

➢ git config --global user.email "[email protected]"

➢ git config --global user.name "Saswati Nayak"

Create a directory which will house your BSP development

➢ mkdir yocto_rba5d2x

➢ cd yocto_rba5d2x

➢ mkdir sources

➢ cd sourcesls

Clone meta-rba5d2x layer with the proper branch ready.

➢ git clone https://github.com/rugged-board/meta-rba5d2x.git -b sumo-rba5d2x

Clone poky git repository with the proper branch ready.

➢ git clone https://github.com/rugged-board/poky.git -b sumo-rba5d2x

Clone meta-openembedded git repository with the proper branch ready.

➢ git clone git://git.openembedded.org/meta-openembedded -b sumo

Clone meta-iot-cloud git repository with the proper branch ready.

➢ git clone https://github.com/intel-iot-devkit/meta-iot-cloud.git -b sumo

come back from the sources directory to configure the build system and start the build process.

➢ Cd ../

Initialize build directory.


➢ source sources/poky/oe-init-build-env

Building
SD Card Flash Images:

➢ For rugged board a5d2x(SDCARD)

i) Change the machine name to "rugged-board-a5d2x-sd1" in "conf/local.conf" as below.

➢ vi conf/local.conf

ii) Set the machine as below and save the file

➢ MACHINE ?= "rugged-board-a5d2x-sd1"

iii) Compile the images for SDCARD Flash using below command.

➢ bitbake rb-sd-core-image-minimal

iv) After completion of this compiling please go to below path to get the SDCARD
Flash images.

➢ cd tmp/deploy/images/rugged-board-a5d2x-sd1/

NOR Flash Images:

For rugged board a5d2x(NOR)

i) Change machine name to "rugged-board-a5d2x" in conf/local.conf as below.

➢ vi conf/local.conf

ii) Set the machine as below and save the file.

➢ MACHINE ?= "rugged-board-a5d2x"

o iii) Compile the images for NOR Flash using below command.

➢ bitbake rb-nor-core-image-minimal

iv) After completion of this compiling, please go to below path to get the NOR Flash images.

➢ cd tmp/deploy/images/rugged-board-a5d2x/
ERRORS

ERROR: OE-core's config sanity checker detected a potential misconfiguration. Either fix the cause of
this error or at your own risk disable the checker (see sanity.conf). Following is the list of potential
problems / advisories:

Do not use Bitbake as root.

SOLUTION:

touch conf/sanity.conf

After setup build environment, you directly jump into the build directory. so from there, you run the
below command.

ERROR: ExpansionError during parsing


/yocto_rba5d2x/sources/poky/../meta-rba5d2x/recipes-bsp/at91bootstrap/at91bootstrap_git.bb

SOLUTION:
vi /yocto_rba5d2x/sources/poky/../meta-rba5d2x/recipes-bsp/at91bootstrap/at91bootstrap_git.bb

require at91bootstrap.inc

DEFAULT_PREFERENCE = "-1"

SRCREV = "${AUTOREV}"

SRC_URI = "https://github.com/linux4sam/at91bootstrap.git;protocol=git \ "

S = "${WORKDIR}/git"

PV = "3.8+git${SRCPV}"

LIC_FILES_CHKSUM = "file://main.c;endline=27;md5=a2a70db58191379e2550cbed95449fbd"

ERROR: data-image-1.0-r0 do_install: Function failed: do_install (log file is located at


/yocto_rba5d2x/build/tmp/work/cortexa5hf-neon-poky-linux-musleabi/data-image/1.0-r0/temp/
log.do_install.29306)

ERROR: Logfile of failure stored in: /yocto_rba5d2x/build/tmp/work/cortexa5hf-neon-poky-linux-


musleabi/data-image/1.0-r0/temp/log.do_install.29306.
Log data follows:

DEBUG: Executing python function extend_recipe_sysroot

NOTE: Direct dependencies are ['/yocto_rba5d2x/sources/poky/../meta-rba5d2x/recipes-devtools/upm-


data/upm-data_1.7.0.bb:do_populate_sysroot', '/yocto_rba5d2x/sources/poky/../meta-rba5d2x/recipes-
support/lighttpd-data/lighttpd-data_1.4.48.bb:do_populate_sysroot',
'virtual:native:/yocto_rba5d2x/sources/poky/meta/recipes-devtools/pseudo/
pseudo_git.bb:do_populate_sysroot',
'/yocto_rba5d2x/sources/poky/../meta-rba5d2x/recipes-devtools/mraa-data/mraa-
data_2.0.0.bb:do_populate_sysroot', '/yocto_rba5d2x/sources/poky/meta/recipes-devtools/gcc/gcc-
runtime_7.3.bb:do_populate_sysroot', '/yocto_rba5d2x/sources/poky/meta/recipes-devtools/quilt/quilt-
native_0.65.bb:do_populate_sysroot', '/yocto_rba5d2x/sources/poky/meta/recipes-devtools/gcc/gcc-
cross_7.3.bb:do_populate_sysroot',
'/yocto_rba5d2x/sources/poky/meta/recipes-core/musl/musl_git.bb:do_populate_sysroot',
'/yocto_rba5d2x/sources/poky/../meta-rba5d2x/recipes-support/libmodbus-data/libmodbus-
data_3.1.4.bb:do_populate_sysroot']

NOTE: Installed into sysroot: ['pseudo-native']

NOTE: Skipping as already exists in sysroot: ['upm-data', 'lighttpd-data', 'mraa-data', 'gcc-runtime', 'quilt-
native', 'gcc-cross-arm', 'musl', 'libmodbus-data', 'python3', 'libjpeg-turbo', 'zlib', 'libpcre', 'openssl', 'json-
c', 'libgcc', 'linux-libc-headers', 'autoconf-native', 'zlib-native', 'binutils-cross-arm', 'libmpc-native', 'xz-
native', 'libtool-native', 'automake-native', 'texinfo-dummy-native', 'gnu-config-native', 'flex-native', 'gmp-
native', 'mpfr-native', 'bsd-headers', 'sqlite3', 'libffi', 'xz', 'gdbm', 'bzip2', 'readline', 'cryptodev-linux', 'm4-
native', 'bison-native', 'gettext-minimal-native', 'opkg-utils', 'ncurses']

DEBUG: Python function extend_recipe_sysroot finished

DEBUG: Executing shell function do_install

/yocto_rba5d2x/build/tmp/work/cortexa5hf-neon-poky-linux-musleabi/data-image/1.0-r0/temp/
run.do_install.29306: 131: /yocto_rba5d2x/build/tmp/work/cortexa5hf-neon-poky-linux-musleabi/data-
image/1.0-r0/temp/run.do_install.29306: /usr/sbin/mkfs.jffs2: not found

WARNING: exit code 127 from a shell command.

ERROR: Function failed: do_install (log file is located at /yocto_rba5d2x/build/tmp/work/cortexa5hf-


neon-poky-linux-musleabi/data-image/1.0-r0/temp/log.do_install.29306)

ERROR: Task (/yocto_rba5d2x/sources/poky/../meta-rba5d2x/recipes-devtools/data-image/data-


image_1.0.bb:do_install) failed with exit code '1'NOTE: Tasks Summary: Attempted 1803 tasks of which
5 didn't need to be rerun and 1 failed.

SOLUTION:

apt-get install mtd-utils


Relocating the Docker root directory
Before relocating the docker root directory was in var/lib/docker.
Now if we want to change the root location to any user location the procedure as below.
1. Stop the Docker services
➢ sudo systemctl stop docker
➢ sudo systemctl stop docker.socket
➢ sudo systemctl stop containerd
2. Create the necessary directory structure into which to move Docker root by running the following command.
This directory structure must reside on a file system with at least 50 GB free disk space. Significantly more disk
space might be required depending on your daily ingestion volumes and data retention policy.
➢ sudo mkdir -p /new_dir_structure
e.g:- sudo mkdir -p /home/phytec/DOCKER
3. Move Docker root to the new directory structure:
➢ sudo mv /var/lib/docker /new_dir_structure

e.g:- sudo mv /var/lib/docker /home/phytec/DOCKER


4. Edit the file /etc/docker/daemon.json. If the file does not exist, create the file by running the following
command
➢ sudo vim /etc/docker/daemon.json

Add the following information to this file:


{
"data-root": "/new_dir_structure/docker"
}
5. After the /etc/docker/daemon.json file is saved and closed, restart the Docker services:
➢ sudo systemctl start docker
6. Validate the new Docker root location:
➢ docker info -f '{{ .DockerRootDir}}'

imx6ul:
ERROR: OE-core's config sanity checker detected a potential misconfiguration. Either fix the cause of
this error or at your own risk disable the checker (see sanity.conf). Following is the list of potential
problems / advisories:

Do not use Bitbake as root.

Touch conf/sanity.conf

vi source/poky/meta/classes/sanity.bbclass----740

wic need to comment


root@83e45ac07262:/home/PHYTEC_BSPs/yocto_imx6ul/sources/meta-phytec/conf/machine/
include#

error
Python can't change the filesystem locale after loading so we need a UTF-8 when
Python starts or things won't work.

$ export LC_ALL="en_US.UTF-8"
$ bitbake core-image-base

docker images
docker ps -a
docker start brave_swirles
docker exec -it 4123baafedcf /bin/bash
docker stop container_name
docker rm container_name
vim /etc/apt/sources.list
apt-get update
apt-get upgrade
//apt update && apt-get install -y linux-headers-*
///etc/apt/sources.list.d dpkg --get-selections | grep linux-image

apt update && apt-get install -y linux-headers-$(uname -r)


apt-get install linux-image-5.15.0-107-generic
apt-get install linux-image-extra-5.15.0-107-generic
apt-get install linux-headers-5.15.0-107-generic
apt-get install linux-tools-5.15.0-107-generic
apt-get install linux-modules-5.15.0-107-generic
apt-get install linux-modules-extra-5.15.0-107-generic

apt-get install build-essential kmod

You might also like