-
Notifications
You must be signed in to change notification settings - Fork 109
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
Building on linux (Ubuntu)... getting permission problems (due to Docker running as root?) #449
Comments
Hello @mflint Matthew, Sorry to read you're experiencing this issue. Can you ensure to
On linux, you might get into problems when docker runs as a different user than your current user (docker typically runs as root) |
I think I can close this - I’ve worked around it by making my own Dockerfile, and putting build steps into a makefile. You were correct - it was a Docker permissions issue, running as root on Linux. |
Thank you for the feedback. |
Interesting. I’ll look at your test suite to see what’s different with my setup. |
One of the main difference is that the script runs inside a container on Amazon Linux 2. Builds on Amazon Linux do not trigger docker and start I started an Ubuntu VM to reproduce your issue. |
I confirm that a docker build ( Error is
This is most probably due because the current user can not read/write the docker shared socket file. |
The solution is to add your current user ( sudo usermod -aG docker $USER Here is the full script I used #!/bin/bash
sudo apt update && sudo apt -y upgrade
# Install Swift 6.0.3
sudo apt-get -y install \
binutils \
git \
gnupg2 \
libc6-dev \
libcurl4-openssl-dev \
libedit2 \
libgcc-13-dev \
libncurses-dev \
libpython3-dev \
libsqlite3-0 \
libstdc++-13-dev \
libxml2-dev \
libz3-dev \
pkg-config \
tzdata \
unzip \
zlib1g-dev
wget https://download.swift.org/swift-6.0.3-release/ubuntu2404-aarch64/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu24.04-aarch64.tar.gz
tar xfvz swift-6.0.3-RELEASE-ubuntu24.04-aarch64.tar.gz
export PATH=/home/ubuntu/swift-6.0.3-RELEASE-ubuntu24.04-aarch64/usr/bin:"${PATH}"
swift --version
# Install Docker
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Add the current user to the docker group
sudo usermod -aG docker $USER
# LOGOUT and LOGIN to apply the changes
exit
# reconnect with ssh, then
export PATH=/home/ubuntu/swift-6.0.3-RELEASE-ubuntu24.04-aarch64/usr/bin:"${PATH}"
# clone a project
git clone https://github.com/swift-server/swift-aws-lambda-runtime.git
# build the project
cd swift-aws-lambda-runtime/Examples/HelloWorld/
swift package archive --allow-network-connections docker This produces
|
I have added a Note in the deployment guide. |
Thank-you @sebsto, but that's different from the error that I reported. I was seeing problems with the archive stage reading files from the disk. (My user was already in the Don't worry about it - I'll do some investigations here :) |
You’re correct. I saw the exact same error on macOS when multiple build attempts from different users or systems. (Docker and native for example) Can you try again from scratch (after having deleted Is the error systematic ? |
@sebsto When building Can you try to build
|
Add a note in the deployment guide to inform Linux user they must have correct permissions to use docker on their system. ### Motivation: Build instructions fail on a fresh Ubuntu installation. See this error report. #449 ### Modifications: Add a note in the deployment guide that Linux user must add their user in the `docker` group. ### Result: Hopefully, Linux users will not experience error at first use of `swift package archive`
@mflint ACK. Will do. Thanks ! |
Expected behavior
I'd like to be able to build the lambdas for Arm using a Linux host, because a buying a chonky Raspberry Pi is much cheaper than a new MacBook with Apple Silicon:
Actual behavior
The archiving stage fails with a permission error:
(Wild guess: maybe this is due to the Docker container running as root, so the build artefacts are owned by root? ¯\_(ツ)_/¯ )
Steps to reproduce
make
andzip
swift package archive --allow-network-connections docker
If possible, minimal yet complete reproducer code (or URL to code)
No response
What version of this project (
swift-aws-lambda-runtime
) are you using?38cc01a
Swift version
Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: aarch64-unknown-linux-gnu
Linux heslop 6.11.0-1005-raspi #5-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 22 13:24:30 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
Amazon Linux 2 docker image version
SWIFT_PLATFORM=amazonlinux2, SWIFT_BRANCH=swift-6.0.3-release
The text was updated successfully, but these errors were encountered: