cross platform enablement for the yoctoproject with containers · cross platform enablement for the...

40
ELC 2017 – Randy Witt – Intel Open Source Technology Center Cross platform enablement for the yocto project with containers

Upload: vanliem

Post on 06-May-2018

218 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

ELC 2017 – Randy Witt – Intel Open Source Technology Center

Cross platform enablement for the yocto project with containers

Page 2: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

Why’d I even do this?My personal problems

Page 3: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

3

• Yocto Project QA (Autobuilder) builds on multiple distros

• On failure what are the options?

• ssh in, clone repo, set up build dir

• Create a virtual machine and try there

• Way too much overhead for me

THE multiple distro Problem

Page 4: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

4

• Ctrl-c may not clean up all processes

• Must manually find the processes and kill them

• May not even know the processes are there

Bitbake SOMETIMES LEAKS processes

Page 5: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

Quick overviewcontainers As a SOlution

Page 6: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

6

• Leverage Linux® kernel features

• namespaces for isolation (pid, network, mount)

• Running a container can be as simple as using “unshare”

• cgroups for process encapsulation and resource management

• Restrict number of cores, amount of memory, …

• All processes for the container run in a cgroup so can kill at cgroup level

• Most things that run containers, leverage these kernel features

• docker, lxc, …

Containers aren’t magic

Page 7: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

7

Inside container

Pid namespace examplepokyuser@6325b7c8feaf:~$ sleep 5000 &[1] 32pokyuser@6325b7c8feaf:~$ ps -C sleep -o pid,start,args

PID STARTED COMMAND32 15:24:03 sleep 5000

~% ps -C sleep -o pid,start,argsPID STARTED COMMAND

8257 15:24:03 sleep 5000

Outside container

Page 8: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

8

• Use a Dockerfile to create an image

• Dockerfile used to install software to the image and configure it

• A container uses a temporary instance of the image

• Modifications to the filesystem instance aren’t preserved

Docker

Page 9: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

9

sample dockerfileFROM ubuntu-16.04

RUN apt-get install python

CMD echo “Hello from inside the container!”

Page 10: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

10

• --rm: Remove the container after it exits

• -it: Interactive terminal with a tty

• -v: bind mount /foo to the container as /bar

• c1: Name of the image to run

Docker rundocker run --rm -it -v /foo:/bar c1

Page 11: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

11

Linux/foo

Page 12: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

12

Linux/foo

docker run –v /foo:/bar c1

Page 13: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

13

Linux/foo

docker run –v /foo:/bar c1

Docker

Page 14: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

14

Linux

c1

/foo

docker run –v /foo:/bar c1

Docker

Page 15: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

15

Linux

/barc1

/foo

docker run –v /foo:/bar c1

Docker

Page 16: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

16

Linux

/barc1

/foo

docker run –v /foo:/bar c1

Docker

docker run –v /foo:/baz c2

Page 17: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

17

Linux

/barc1 c2

/foo

docker run –v /foo:/bar c1

docker run –v /foo:/baz c2

Docker

/baz

Page 18: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

Yocto Project containersWhat’s available?

Page 19: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

19

• Drops to a shell where you follow normal Yocto Project instructions

• Default based on Ubuntu 14.04

• Can use a different distro

Poky container

docker run --rm -it -v /home/myuser/mystuff:/workdir crops/poky--workdir=/workdir

docker run --rm -it -v /home/myuser/mystuff:/workdircrops/poky:fedora-24 --workdir=/workdir

Page 20: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

20

• --workdir: The working directory when dropped to the shell

Poky containerdocker run --rm -it -v /home/myuser/mystuff:/workdir crops/poky--workdir=/workdir

Page 21: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

21

• debian-8• fedora-22• fedora-23• fedora-24• fedora-25• opensuse-13.2• opensuse-42.1

• opensuse-42.2• ubuntu-14.04• ubuntu-16.04• ubuntu-16.10

POKY CONTAINER distrosdocker run --rm -it -v /home/myuser/mystuff:/workdircrops/poky:opensuse-42.2 --workdir=/workdir

Page 22: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

22

https://www.youtube.com/watch?v=vt18U5twrgw

Poky container screencast

Page 23: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

23

• Downloads an extensible sdk and drops to a shell ready to run sdkcommands

• If the sdk has already been installed and setup, just leave off the url

Extensible sdk container

docker run --rm -it -v /home/myuser/sdkstuff:/workdircrops/extsdk-container--url http://someserver/extensible_sdk_installer.sh

docker run --rm -it -v /home/myuser/sdkstuff:/workdircrops/extsdk-container

Page 24: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

24

https://www.youtube.com/watch?v=L-sXqUoU49Y

extsdk container screencast

Page 25: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

25

• Runs toaster

• -p: Forwards port 8000 in the container to 127.0.0.1:18000

toaster container

docker run -it --rm -p 127.0.0.1:18000:8000-v /home/myuser/toasterstuff:/workdir crops/toaster

Page 26: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

26

https://www.youtube.com/watch?v=LJ9TBsuMwFA

Toaster container screencast

Page 27: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

OTHER PLATFORMSRunning the containers on the macOS™ operating system

Page 28: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

28

• Setup

• Instructions at https://github.com/crops/docker-win-mac-docs/wiki

• Runs in a hypervisor (intended to be transparent)

• Uses a Docker volume rather than bind mount

Differences

Page 29: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

29

Linux

/barc1 c2

/foo

docker run –v /foo:/bar c1

docker run –v /foo:/baz c2

Docker

/baz

Page 30: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

30

Linux

/barc1 c2

/foo

Docker

/bazdocker run –v vol:/bar c1

docker run –v vol:/baz c2

Page 31: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

31

Linux

/barc1 c2

/foo

Docker

/baz

macOS

docker run –v vol:/bar c1

docker run –v vol:/baz c2

Page 32: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

32

Linux

/barc1 c2

/foo

Docker

/baz

macOS

Hypervisor

docker run –v vol:/bar c1

docker run –v vol:/baz c2

Page 33: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

33

Linux

/barc1 c2docker run –v vol:/bar c1

docker run –v vol:/baz c2

Docker

/baz

Hypervisor

macOS

vol

Page 34: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

34

Linux

/barc1 c2docker run –v vol:/bar c1

docker run –v vol:/baz c2

Docker

/baz

Hypervisor

macOS

vol

docker start samba

Page 35: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

35

Linux

/barc1 c2docker run –v vol:/bar c1

docker run –v vol:/baz c2

Docker

Hypervisor

macOS

samba

docker start samba

/baz /workdir

vol

Page 36: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

36

https://www.youtube.com/watch?v=w9_Wt6iQK3g

Other platform screencast

Page 37: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

Questions?

37

Page 38: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

38

• poky container• https://github.com/crops/poky-container

• https://hub.docker.com/r/crops/poky/

• extsdk container• https://github.com/crops/extsdk-container

• https://hub.docker.com/r/crops/extsdk-container/• toaster container• https://github.com/crops/toaster-container

• https://hub.docker.com/r/crops/toaster/

More info

Page 39: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •

39

macOS™ are registered trademarks of Apple Inc.

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.

“Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries. Docker, Inc. and other parties may also have trademark rights in other terms used herein.”

Credits

Page 40: Cross platform enablement for the yoctoproject with containers · Cross platform enablement for the yoctoproject with containers. Why’d I even do this? My personal problems. 3 •