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

huangapple go评论107阅读模式
英文:

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

问题

我正在学习容器和Docker,并且尝试使用go-migrate运行一个容器,但是我遇到了这个错误:

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 |
--------------------
错误:解决失败:"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" 未成功完成:退出代码:100

我正在使用一台M1 MacBook,并且Dockerfile如下:

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
英文:

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

答案1

得分: 1

还有一个go install选项可以安装migrate。由于您正在使用go镜像,因此通过这种方式安装会更容易。

例如:

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

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

huangapple
  • 本文由 发表于 2023年7月4日 09:44:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76608948.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定