Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/11385 #104

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ point.
docker run --rm -it -v myvolume:/workdir crops/poky --workdir=/workdir
```

Let's discuss the options:
* **_--workdir=/workdir_**: This causes the container to start in the directory
Available options:
* **_--help_**: show help message and exit.
* **_--workdir=WORKDIR_**: This causes the container to start in the directory
specified. This can be any directory in the container. The container will also use the uid and gid
of the workdir as the uid and gid of the user in the container.
* **_--id=ID_**: uid and gid to use for the user inside the container. It should be in the form uid:gid.

This should put you at a prompt similar to:
The previous example should put you at a prompt similar to:
```
pokyuser@3bbac563cacd:/workdir$
```
At this point you should be able to follow the same instructions as described
in https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html
in https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html#building-your-image to build an image.

Note that the container should not be used to clone Poky or obtain any other meta-data, which must be done
_outside_ the container using common tools like Git, as stated in https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html#use-git-to-clone-poky
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true. The instructions above tell you to create your workspace and pass that in as a volume. If you pass in a directory that does not exist, docker will "conveniently" create it inside the container as root.

For instance, this series of commands works just fine (on Linux) and poky is cloned with my user permissions:

ttorling@chiron:/srv/build/ttorling$ mkdir crops-workspace
ttorling@chiron:/srv/build/ttorling$ docker run --rm -it -v /srv/build/ttorling/crops-workspace:/workdir crops/poky --workdir=/workdir
pokyuser@14be76de76a9:/workdir$ git clone https://git.yoctoproject.org/poky.git
Cloning into 'poky'...
remote: Enumerating objects: 646774, done.
remote: Counting objects: 100% (1691/1691), done.
remote: Compressing objects: 100% (425/425), done.
remote: Total 646774 (delta 1364), reused 1419 (delta 1260), pack-reused 645083
Receiving objects: 100% (646774/646774), 204.82 MiB | 3.45 MiB/s, done.
Resolving deltas: 100% (471021/471021), done.
pokyuser@14be76de76a9:/workdir$ exit
exit
ttorling@chiron:/srv/build/ttorling$ ls -la crops-workspace/
total 12
drwxrwxr-x  3 ttorling ttorling 4096 May 24 09:20 .
drwxr-xr-x 73 ttorling ttorling 4096 May 24 09:18 ..
drwxr-xr-x 12 ttorling ttorling 4096 May 24 09:21 poky

There are also instructions for Windows and Mac OS to use the samba container, because those native file systems are not compatible with Linux.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On further review of the original bug, the issue being discussed there is the lack of the repo tool in the image. This has already been discussed and rejected crops/yocto-dockerfiles#42

The solution is to build a derivative container with the tools you need for your specific use case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dockerfile.repo:

FROM crops/poky:ubuntu-18.04

USER root

RUN  wget https://storage.googleapis.com/git-repo-downloads/repo -O /usr/local/bin/repo && \
     chmod +x /usr/local/bin/repo

# We always need to return to the usersetup and ENTRYPOINT
USER usersetup
ENV LANG=en_US.UTF-8

ENTRYPOINT ["/usr/bin/distro-entry.sh", "/usr/bin/dumb-init", "--", "/usr/bin/poky-entry.py"]

Build:
docker build -t crops/poky-repo:ubuntu-18.04 -f ./Docker.repo .

Execution:

ttorling@chiron:/srv/build/ttorling$ docker run --rm -it -v /srv/build/ttorling/crops-workspace:/workdir crops/poky-repo:ubuntu-18.04 --workdir=/workdir
pokyuser@aa90fb6f937a:/workdir$ which repo
/usr/local/bin/repo
pokyuser@aa90fb6f937a:/workdir$ repo --help
usage: repo COMMAND [ARGS]

repo is not yet installed.  Use "repo init" to install it here.

The most commonly used repo commands are:

  init      Install repo in the current working directory
  help      Display detailed help on a command

For access to the full online help, install repo ("repo init").

Bug reports: https://issues.gerritcodereview.com/issues/new?component=1370071

Because repo will always try to "phone home" and update itself, you will likely need to rebuild this container from time to time to have the latest version and avoid warnings.

2 changes: 1 addition & 1 deletion poky-entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
parser = argparse.ArgumentParser()
parser.add_argument('--workdir', default='/home/pokyuser',
help='The active directory once the container is running. '
'In the abscence of the "id" argument, the uid and '
'In the absence of the "id" argument, the uid and '
'gid of the workdir will also be used for the user '
'in the container.')

Expand Down