Cross-posting from How to install Swift lang using Docker on linux/amd64? Getting `invalid driver name: swift-driver`? - Stack Overflow for visibility.
I saw the official Swift Dockerfile, for ubuntu:22.04, but it is not for amd64. So then I found a non-official one at swiftarm/swift, and tried installing it like this:
Dockerfile:
FROM --platform=linux/amd64 swiftarm/swift
RUN swift -v
CLI:
$ docker build -f Dockerfile.swift --platform linux/amd64 . -t test-swift
[+] Building 136.4s (6/6) FINISHED docker:desktop-linux
=> [internal] load .dockerignore 0.0s
=> => transferring context: 45B 0.0s
=> [internal] load build definition from Dockerfile.swift 0.0s
=> => transferring dockerfile: 76B 0.0s
=> [internal] load metadata for docker.io/swiftarm/swift:latest 2.5s
=> [auth] swiftarm/swift:pull token for registry-1.docker.io 0.0s
=> [1/2] FROM docker.io/swiftarm/swift@...
=> => extracting ...
=> ERROR [2/2] RUN swift -v 0.5s
------
> [2/2] RUN swift -v:
0.198 error: invalid driver name: swift-driver
------
Dockerfile.swift:2
--------------------
1 | FROM swiftarm/swift
2 | >>> RUN swift -v
3 |
--------------------
ERROR: failed to solve: process "/bin/sh -c swift -v" did not complete successfully: exit code: 1
ELIFECYCLE Command failed with exit code 1.
It fails with:
error: invalid driver name: swift-driver
That is what I get if I tried installing swift from source in another way too. Here are the official swift releases.
I need it on linux/amd64
because I would like to host this on Render.com, which says:
The Docker image must be built for the
linux/amd64
platform.
How can I get Swift building through Docker on linux/amd64
? Such that swift -v
doesn't throw that error?
If nothing else, what does that error invalid driver name: swift-driver
mean?
I tried this as well, according to About | Swift Community Repository, but no go:
FROM --platform=linux/amd64 amd64/ubuntu:lunar
RUN apt-get update -y -q
RUN apt-get upgrade -y -q
RUN apt-get -y install curl
RUN curl -s https://archive.swiftlang.xyz/install.sh | bash
RUN apt-get -y install swiftlang
RUN swift -v
Same error.
I am running docker build
on my Mac, Apple M3 Pro Sonoma 14.1.1
.