dockergocontainersmigrate

How can I install go-migrate on a container in Docker?


I am studying containers and Docker, and I am trying to run a container with go-migrate but I am getting this error:

Dockerfile:33
--------------------
  32 |
  33 | >>> RUN curl -s https://packagecloud.io/install/repositories/golang-migrate/migrate/script.deb.sh | bash && \
  34 | >>>     apt-get update && \
  35 | >>>     apt-get install migrate
  36 |
--------------------
ERROR: failed to solve: process "/bin/sh -c curl -s https://packagecloud.io/install/repositories/golang-migrate/migrate/script.deb.sh | bash &&     apt-get update &&     apt-get install migrate" did not complete successfully: exit code: 100

I am using a M1 Macbook and the dockerfile is:

FROM golang:1.20.3

RUN curl -s https://packagecloud.io/install/repositories/golang-migrate/migrate/script.deb.sh | bash && \
apt-get update && \
apt-get install migrate

Solution

  • There is also an go install option to install migrate. Since you are using a go image hence it would be easier to install it that way e.g.

    FROM FROM golang:1.20.3
    RUN go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@latest