Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello everyone, a couple of developers are using Linux desktop systems with multiple user accounts.

Options
UQ958DA4U
UQ958DA4U Posts: 232 🧑🏻‍🚀 - Cadet
edited November 2020 in Docker

Hello everyone,

a couple of developers are using Linux desktop systems with multiple user accounts. Their own is never UID 1000. It seems that docker/sdk makes a mistake here or has hardcoded values for UID 1000. If I start our project on such a system with a user who has UID 1001, directory permissions are incorrectly set to UID 1000, which makes loggers and caches unable to write their files,

docker/sdk Version 1.23

How can we get this resolved? Any ideas?

PS: This can easily be replicated by setting up a VM and giving your user a different UID than 1000.

Comments

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet
    edited November 2020
    Options

    It worked fine for me with any UID on my Linux. However docker can have some cross-platform problems. I am not aware of it.

    docker/sdk currently bakes UID when building docker images, so spryker user becomes with the UID of your user on host.

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet
    Options

    Could you run this one (name of image can be different based on your deploy.y,l) ?

    docker run -it spryker_cli:dev id
    
  • UQ958DA4U
    UQ958DA4U Posts: 232 🧑🏻‍🚀 - Cadet
    Options

    Ok, first thing's first:

    problems@failwhale:~/shop$ id
    uid=1001(problems) gid=1001(problems) groups=1001(problems),997(docker)
    problems@failwhale:~/shop$ docker run -it anon_dev_cli:dev id
    uid=1001(spryker) gid=82(www-data) groups=82(www-data)
    problems@failwhale:~/shop$ docker/sdk cli id
    -->  DEVELOPMENT MODE   
    uid=1001(spryker) gid=82(www-data) groups=82(www-data)
    

    Starting docker/sdk works just fine, BUT when I reach the point where the demo data gets initialized, a log is trying to get written and that fails:

    Command propel-copy-schema [vendor/bin/console propel:schema:copy] (In progress...)
    Store: DE | Environment: docker
    Clean schema directory
    Copy and merge schema files
    UnexpectedValueException - Exception: There is no existing directory at "/var/log/spryker/DE/ZED" and it could not be created: Permission denied 
    in /data/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php (172)
    
    Command: vendor/bin/console propel:schema:copy
    
    Trace: 
    #0 /data/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php(100): Monolog\Handler\StreamHandler->createDir()
    #1 /data/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(42): Monolog\Handler\StreamHandler->write(Array)
    ...
    

    The interesting thing here is the "Permission denied". If I have a peak into the log directory, this is how it's looking like:

    problems@failwhale:~/shop$ docker/sdk cli
    -->  DEVELOPMENT MODE   
    
    ┌────┐           ┌─┐            ┌───┬─┐ ┌───┐
    │ ───┼───┬─┬─┬─┬─┤ ├─┬───┬─┬─┐  │ ┌─┤ │ └│ │┘
    ├─── │ ┼ │ ┌─┤ │ │───┤ ┼─┤ ┌─┘  │ └─┤ └─┬│ │┐
    └────┤  ┌┴─┘ ├─┐ ├─┴─┴───┴─┘    └───┴───┴───┘
         └──┘    └───┘
    
    ╭─/data | Store: DE | Env: docker | Debug: (.) | Testing: (.)
    ╰─$ ls -la /var/log/spryker
    total 12
    drwxr-xr-x 2 1000 spryker 4096 Nov  4 21:22 .
    drwxr-xr-x 1 root root    4096 Nov  4 21:19 ..
    -rw-r--r-- 1 root root    1521 Nov  4 21:22 supervisord.log
    

    This line is the interesting one:

    drwxr-xr-x 2 1000 spryker 4096 Nov  4 21:22 .
    

    To me, it's looking like the image gets built properly but some process chowns that folder in a hardcoded process or something of that magnitude.

    Specs of what I'm testing with:

    problems@failwhale:~/shop$ docker --version
    Docker version 19.03.13, build 4484c46d9d
    problems@failwhale:~/shop$ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 20.04.1 LTS
    Release:    20.04
    Codename:   focal
    

    Any ideas?

  • UQ958DA4U
    UQ958DA4U Posts: 232 🧑🏻‍🚀 - Cadet
    Options
  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet
    Options
    1. I would advise to use <php://stderr> for logs.
    2. /var/log/spryker is a volume in docker-compose. It seems it is inited with 1000 UID.
  • UQ958DA4U
    UQ958DA4U Posts: 232 🧑🏻‍🚀 - Cadet
    Options

    /var/log/spryker is a volume in docker-compose. It seems it is inited with 1000 UID.

    How can I change this behaviour? Again, this means docker/sdk is broken for this use case where the user does not have UID 1000.

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet
    Options

    I agree it is a problem we need to solve. Probably it is outside of docker/sdk responsibility as it is docker-compose side effect.

    However if you use <php://stderr> for logs docker/sdk works regardless UID. And that is the only proper way to do logging in containers. Files must not be used.

  • UQ958DA4U
    UQ958DA4U Posts: 232 🧑🏻‍🚀 - Cadet
    Options

    One more follow up question: How will I use docker/sdk logs then? What it normally does is to tail the logs.

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet
    Options

    There are 2 options:

    1. docker logs spryker_yves_1 -f Using docker logs.
      1. You can use dashboard service:
        dashboard:
            engine: dashboard
            endpoints:
                spryker.local:
    

    There is a link to UI that shows logs from all containers.

  • sprymiker
    sprymiker Cloud Platform Architect Sprykee Posts: 781 🧑🏻‍🚀 - Cadet
    Options

    We are thinking about extending docker/sdk logs to manage logs in more appropriate way