Replies: 1 comment
-
The error
Solutions:1. Check Docker VersionEnsure your Docker version supports BuildKit (version 18.09+). docker --version If it's an older version, update Docker to the latest version. 2. Enable Docker BuildKitIf you are running a compatible Docker version, you might need to explicitly enable BuildKit. You can do this by setting the environment variable: export DOCKER_BUILDKIT=1 Then try building the Docker image again: docker build -t <image-name> . Alternatively, you can enable BuildKit permanently by editing the Docker daemon configuration:
{
"features": {
"buildkit": true
}
}
sudo systemctl restart docker 3. Remove the Syntax DirectiveIf you're not using any specific BuildKit features, you can remove the Here’s the updated Dockerfile without the syntax directive: Updated Dockerfile (Without BuildKit Directive):# Use the official Ubuntu base image
FROM ubuntu:latest
# Install required packages in a single step with cache cleanup
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
curl \
unzip \
ca-certificates \
gnupg \
lsb-release && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Set up Node.js LTS
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Download and install ngrok
RUN curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc | tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | tee /etc/apt/sources.list.d/ngrok.list && \
apt-get update && \
apt-get install -y ngrok && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install tmux
RUN apt-get update && apt-get install -y tmux && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install PM2 globally using npm
RUN npm install -g pm2 Now, try building the Dockerfile again: docker build -t <image-name> . Removing the BuildKit syntax directive should resolve the issue if you’re not specifically relying on BuildKit features. |
Beta Was this translation helpful? Give feedback.
-
If the error "ERROR: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Head "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied" persists then
By default, Docker commands require root privileges. Adding your user to the docker group allows you to execute Docker commands without needing sudo.
sudo usermod -aG docker $USER
After running this command, you’ll need to log out and log back in to apply the group changes:
Check if you can run Docker commands now:
And if still error persists, restart the machine.
Beta Was this translation helpful? Give feedback.
All reactions