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

Docker grid incompatibilities #1483

Closed
OmarElawady opened this issue Nov 22, 2021 · 1 comment
Closed

Docker grid incompatibilities #1483

OmarElawady opened this issue Nov 22, 2021 · 1 comment
Assignees
Labels
type_feature New feature or request

Comments

@OmarElawady
Copy link
Contributor

OmarElawady commented Nov 22, 2021

For people converting docker images to an flist, Here's a non-comprehensive list of differences that will make a zmachine not working when deployed using the generated flist. docker image inspect <image_name> should give sufficient information.

  • WorkingDir
    The working directory of the container/zmachine entrypoint. Currently all zmachines are started with / as their CWD.
  • Env
    List of default values for a set of environment variables when they are not provided by the user. They are handles by zos, but the PATH variable needs special handling (not for long).
  • User
    What is the user the entrypoint process should start with.
  • /etc/hosts
    The file gets populated when a docker container gets started but it doesn't for zmachines

These values are present in /.startup.toml of the generated flist. So the initramfs could be prepared to handle the values in them or they can be parsed in zos and passed to inirarmfs.

To workaround this issue, the entrypoint of the docker image can be wrapped in another shell script to perform the expected docker operations:

Example .startup.toml of redis (can also be found by inspecting the image):

[startup]

[startup.entry]
name = "core.system"

[startup.entry.args]
name = "docker-entrypoint.sh"
args = ["redis-server"]
dir = "/data"

[startup.entry.args.env]
REDIS_DOWNLOAD_URL = "http://download.redis.io/releases/redis-6.2.6.tar.gz"
REDIS_DOWNLOAD_SHA = "5b2b8b7a50111ef395bf1c1d5be11e6e167ac018125055daa8b5c2317ae131ab"
REDIS_VERSION = "6.2.6"
GOSU_VERSION = "1.12"
PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

A new Dockerfile to generate a zmachine-compatible flist:

FROM redis
COPY wrap.sh /
RUN chmod +x /wrap.sh
ENTRYPOINT ["/wrap.sh"]

The wrap.sh file:

#!/bin/sh
echo "127.0.0.1 localhost" >> /etc/hosts # append others as needed
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # until https://github.com/threefoldtech/cloud-container/pull/6 is merged because the one in /etc/environment currently overrides the default path
cd /data
su - root # This is redundant here of course but it should "su - username" if the User is somebody other than the root
exec docker-entrypoint.sh "$@"

And the entrypoint when deploying a zmachine should be /wrap.sh redis-server. The redis-server is the args in .startup.toml.

@muhamadazmy
Copy link
Member

May be we can automate some of the steps in the clout-container image. Setting up /etc/hosts should be handled zos cloud-container. Also setting up default PATH (are you sure that's not the case already). Unfortunately changing working directory and user can only be done after switch_root so has to be handled with a script that is on the rootfs of the VM.

Hence:

  • We also inject the wrapper script in vm rootfs (how about .zosrc becomes the default entrypoint that sets everything up (including env, entrypoint and user and working directory) then exec the actual entrypoint?
  • Or simply document the limitations.

I am not sure if PID 1 can be anything other than root, need to be tested.

@OmarElawady OmarElawady added this to Accepted in 3.0 via automation Dec 13, 2021
@OmarElawady OmarElawady moved this from Accepted to Backlog in 3.0 Dec 13, 2021
@muhamadazmy muhamadazmy removed this from Backlog in 3.0 Dec 28, 2021
@muhamadazmy muhamadazmy added this to Accepted in 3.0.9+ X via automation Dec 28, 2021
@despiegk despiegk removed this from Accepted in 3.0.9+ X Feb 7, 2022
@despiegk despiegk added the type_feature New feature or request label Feb 7, 2022
@despiegk despiegk added this to the later milestone Feb 7, 2022
@xmonader xmonader removed this from the later milestone Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type_feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants