Skip to main content

Building an Image in Docker Container

Introduction

Set up the build environment using container methods.

Set up build environment on host PC:

The build environment is tested under Ubuntu 22.04.

Install required package:

sudo apt install docker.io

Download TechNexion's dockerfile:

wget https://raw.githubusercontent.com/TechNexion/meta-tn-imx-bsp/kirkstone_5.15.71-2.2.0-stable/tools/container/dockerfile

Build the docker container:

sudo docker build -t tn-develop-ubuntu .

Check the built docker container:

$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tn-develop-ubuntu latest b438b5e2e8fb 5 minutes ago 2.15GB
ubuntu 20.04 88bd68917189 8 weeks ago 72.8MB

Use docker container:

Use this docker container to start building Yocto image.

Create a new docker container:

$ sudo docker run -it -u jenkins -v ${directory_in_host_machine}:${directory_in_docker} tn-develop-ubuntu bash
(-v: use to bind volume to the directory in host machine to a directory in docker)
(password: jenkins)

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

jenkins@818cacdead74:/$ cd
jenkins@818cacdead74:~$

Re-entry is required when exiting:

$ sudo docker start <your container id>
$ sudo docker attach <your container id>

e.g.

$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
818cacdead74 tn-develop-ubuntu "bash" 45 minutes ago Exited (0) 19 seconds ago hopeful_villanir

$ sudo docker start 818cacdead74
$ sudo docker attach 818cacdead74