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

Fixing Docker permission issues #2920

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rmoreliovlabs
Copy link
Contributor

@rmoreliovlabs rmoreliovlabs commented Jan 9, 2025

Fix User UID Conflict by Creating rsk User with UID 1000

Description

This PR fixes a problem where there was a UID conflict between files created by containers running with UID 1000 (like those created with the ARROWHEAD-6.3.0 image) and the new user created with UID 1001 in the updated image (ARROWHEAD-6.5.0). The issue happened when trying to access or modify files that were created by older versions of the container. Since the Dockerfile originally created the rsk user with a conflicting UID, any files created by the old container would have the wrong ownership, causing permission issues when a new container with a different UID tried to access them.

To resolve this, I modified the useradd command to explicitly set the rsk user’s UID to 1000, which matches the UID used in the previous image. This ensures consistent file ownership across container versions and prevents the permission issues

How I Tested the Fix:

  1. Create a Boton Instance: I created a Boton instance to simulate the environment using the following command: create mainnet commit fix/docker_rsk_permission_issue db reset duration 2 day

  2. Stop the RSK Service: I stopped the existing RSK service with: sudo systemctl stop rsk

  3. Install Docker: I followed the Docker Install Guide for Ubuntu to install Docker on the system.

  4. Start Docker: sudo systemctl start docker

  5. Build the Docker Image: In the rskj directory, I built the Docker image using the following commands
    cd rskj
    sudo docker build -t testing-image .

  6. Set Up DB Directory:
    mkdir -p tmp/rskj-docker-repro
    cd tmp/rskj-docker-repro
    mkdir db

  7. Run RSKJ with Newer Image (Before Fix): After building the new image with the fix, I tested it by running: sudo docker run -it --rm -v ./db:/var/lib/rsk/.rsk rsksmart/rskj:ARROWHEAD-6.5.0 . This resulted in the following error when trying to create new files due to UID conflict after the upgrade to version 6.4.0 or later (which runs with UID 1001):

2024-12-06-15:33:00.0579 ERROR [db] [main] While mkdir if missing: /var/lib/rsk/database/mainnet/unitrie: Permission denied org.rocksdb.RocksDBException: While mkdir if missing: /var/lib/rsk/database/mainnet/unitrie: Permission denied at org.rocksdb.RocksDB.open(Native Method) at org.rocksdb.RocksDB.open(RocksDB.java:252)

  1. Run RSKJ with New Image (After Fix): sudo docker run -it --rm -v ./db:/var/lib/rsk/.rsk testing. The container started successfully, and no permission errors occurred.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Tests for the changes have been added (for bug fixes / features)
  • Requires Activation Code (Hard Fork)
  • Other information:

Copy link

github-actions bot commented Jan 9, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@rmoreliovlabs rmoreliovlabs force-pushed the fix/docker_rsk_permission_issue branch from f8c4f3b to 4c117a1 Compare January 10, 2025 00:28
Copy link

@vincent89291 vincent89291 left a comment

Choose a reason for hiding this comment

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

Explicit

@rmoreliovlabs rmoreliovlabs marked this pull request as ready for review January 17, 2025 14:05
@rmoreliovlabs rmoreliovlabs force-pushed the fix/docker_rsk_permission_issue branch from 4c3f302 to b9abb24 Compare January 17, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants