5 https://raw.githubusercontent.com/automotive-grade-linux/docs-sources/master/docs/getting-started/docker-container-setup.md
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/getting_started/master/image-development-workflow-getting-started-book.yml -->
12 This section explains how to quickly setup a Docker container environment
13 suitable for using the Yocto Project build system.
14 Within the container environment you can build images using BitBake
15 and create and package AGL applications with a Software Development
16 Kit (SDK) specifically tailored for your target hardware.
18 Docker is an open source tool designed to make it easier to create, deploy,
19 and run applications by using containers.
20 Containers allow a developer to package up an application with all
21 the parts it needs, such as libraries and other dependencies, and ship
22 it all out as one package.
24 The container you set up here is configured for Yocto Project and AGL.
25 This configuration means you do not have to have a native Linux build
27 You can use a system running Microsoft or MacOS.
29 You can learn more about Docker on the
30 [Docker Documentation](https://docs.docker.com/) site.
32 **NOTE:** The information in this section has been tested using a Linux
34 However, as previously mentioned, you could set up a Docker container
35 that works using Windows or MacOS.
37 ## 1. Installing Docker Community Edition (CE)
39 If your build host does not already have
40 [Docker CE](https://docs.docker.com/install/) installed, you must install it.
42 You can find general instructions for installing Docker CE on a Linux system
43 on the [Docker Site](https://docs.docker.com/engine/installation/linux/).
45 You need to download the Docker CE version particular to your operating system.
46 For example, if you are running the Ubuntu 16.04 Linux distribution, you can
48 [Supported Platform](https://docs.docker.com/install/#supported-platforms) checkmark
49 and see the instructions you need to install Docker CE on that platform.
51 Follow the steps to install Docker CE for your particular distribution.
53 [Get Docker CE for Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
54 page describes how to install Docker CE on a build host running the Ubuntu
57 Successful Docker installation is measured by the results of running a "hello world"
61 $ sudo docker run hello-world
63 This message shows that your installation appears to be working correctly.
65 To generate this message, Docker took the following steps:
66 1. The Docker client contacted the Docker daemon.
67 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
69 3. The Docker daemon created a new container from that image which runs the
70 executable that produces the output you are currently reading.
71 4. The Docker daemon streamed that output to the Docker client, which sent it
74 To try something more ambitious, you can run an Ubuntu container with:
75 $ docker run -it ubuntu bash
77 Share images, automate workflows, and more with a free Docker ID:
78 https://hub.docker.com/
80 For more examples and ideas, visit:
81 https://docs.docker.com/get-started/
84 ## 2. Setting Up to Use Docker as a Non-Root User
86 For Linux machines, Docker runs as a root user by default.
87 You can create a docker group and add yourself to it so that you do not
88 have to preface every `docker` command with `sudo`, for example.
90 Follow the instructions on the
91 [Post-installation steps for Linux](https://docs.docker.com/install/linux/linux-postinstall/)
92 page for information on how to create a Docker group and add yourself to the group.
94 Once you have set up to use Docker as a non-root user, you can log out of your
95 system, log back in, and run the "hello world" application again to verify you
96 do not have to use root:
99 $ docker run hello-world
101 This message shows that your installation appears to be working correctly.
103 To generate this message, Docker took the following steps:
104 1. The Docker client contacted the Docker daemon.
105 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
107 3. The Docker daemon created a new container from that image which runs the
108 executable that produces the output you are currently reading.
109 4. The Docker daemon streamed that output to the Docker client, which sent it
112 To try something more ambitious, you can run an Ubuntu container with:
113 $ docker run -it ubuntu bash
115 Share images, automate workflows, and more with a free Docker ID:
116 https://hub.docker.com/
118 For more examples and ideas, visit:
119 https://docs.docker.com/get-started/
122 ## 3. Setting Up a Persistent Workspace
124 Docker images are pre-configured to use a particular User Identifier (uid) and
125 Group Identifier (gid) that allow the Container to use the Yocto Project
127 The `uid:gid` provides a dedicated user account *devel*,
128 which belongs to `uid=1664(devel)` and `gid=1664(devel)`.
130 **NOTE:** The password is `devel`.
132 The `create_container.sh` script as shown in the following
133 section instantiates a new container and shares the following
134 volumes with the build host:
137 The build directory inside the container.
138 This directory is stored in **~/ssd/xdt_$ID**, which is specific to
139 the container's instance ID.
141 * **/home/devel/mirror:**
142 A development mirror stored in **~/ssd/localmirror_$ID**,
143 which is specific to the container's instance ID.
145 * **/home/devel/share:**
146 A development share at **~/devel/docker/share**, which is shared
149 These shared volumes need the proper permissions in order form them
150 to be accessible from the container environment.
151 You can make sure permissions are in order using the following commands:
154 $ mkdir ~/ssd ~/devel
155 $ chmod a+w ~/ssd ~/devel
160 * To gain access from your host on files created within the container, your
161 host account requires to be added to group id 1664.
163 ## 4. Getting the Generic AGL Worker Docker Image
165 You can either locate and install a pre-built image or rebuild the image.
167 ### Using a Pre-Built Image
169 Use the `wget` command to download the latest pre-built Docker image
170 into your local Docker instance.
174 $ wget -O - https://download.automotivelinux.org/AGL/snapshots/sdk/docker/docker_agl_worker-latest.tar.xz | docker load
176 REPOSITORY TAG IMAGE ID CREATED SIZE
177 docker.automotivelinux.org/agl/worker-generic 5.99-95 6fcc19b4e0d7 2 weeks ago 1.56GB
178 jenkins latest 55720d63e328 5 weeks ago 711.9 MB
179 hello-world latest c54a2cc56cbb 5 months ago 1.848 kB
182 After loading the image, identify and export the `IMAGE_ID`.
183 For example, the `IMAGE_ID` given the previous command is "6fcc19b4e0d7".
186 $ export IMAGE_ID=6fcc19b4e0d7
189 ### Building an Image
191 You can build the Docker image using the
192 [docker-worker-generator](https://git.automotivelinux.org/AGL/docker-worker-generator/)
195 ## 5. Starting the Container
197 After you have the image available, use the
198 `create_container` script to start a new, fresh container that is
199 based on the AGL Worker image:
202 The password for the ID "devel" inside the docker image is "devel".
205 $ git clone https://git.automotivelinux.org/AGL/docker-worker-generator
206 $ cd docker-worker-generator
207 $ ./contrib/create_container 0 $IMAGE_ID
209 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
210 4fb7c550ad75 6fcc19b4e0d7 "/usr/bin/wait_for_ne" 33 hours ago Up 33 hours 0.0.0.0:2222->22/tcp, 0.0.0.0:69->69/udp, 0.0.0.0:8000->8000/tcp, 0.0.0.0:10809->10809/tcp agl-worker-odin-0-sdx
213 ## 6. Installing the AGL SDK for Your Target
215 Once you have a new container that is based on the AGL Worker Image, you
216 can copy the SDK Installer to the container and then install
217 the target-specific AGL SDK.
218 With an SDK installed, you are able to develop AGL applications
221 For this section, assume that the SDK is `agl-demo-platform-crosssdk` and was built
222 according to the instructions in the
223 "[Download or Build Your SDK Installer](./app-workflow-sdk.html)"
228 1. **Copy the SDK Installer to the Shared Volume:
232 This is part of the example from the original file.
233 It shows building out the SDK from a container.
235 For example, we could have built the SDK from another worker container listening with SSH on port 2223:
239 ssh -p 2223 devel@mybuilder.local;
240 ... [ prepare build environment ] ...
241 bitbake agl-demo-platform-crosssdk;
242 ... [ build happens in /xdt/build ] ...
247 $ cp /xdt/build/tmp/deploy/sdk/poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-cortexa15hf-neon-toolchain-3.0.0+snapshot.sh ~/share
250 2. Log into your "SDK Container" and install the SDK:
253 $ ssh -p 2222 devel@mysdk.local
254 $ install_sdk ~/share/poky-agl-glibc-x86_64-agl-demo-platform-crosssdk-cortexa15hf-neon-toolchain-3.0.0+snapshot.sh
257 ## 7. Build Your Application
259 Once you have the SDK installed in your container, you are ready
260 to develop your application.
262 "[Create and Build the Application](./app-workflow-build-app.html)"
263 section for more information.
268 This stuff is leftover from the original file.
269 It is pretty generic and I don't think we need to retain it.
271 First, you must source the SDK environment you wish to use (you MUST repeat this step each time you open a new shell):
274 source /xdt/sdk/environment-setup-<your_target>
277 You're then ready to go: get the sources, run the builds ...
280 git clone <your repo for your app>;
282 cmake; make; make package;