Home  >  Article  >  Backend Development  >  How to install go-migrate on a Docker container?

How to install go-migrate on a Docker container?

WBOY
WBOYforward
2024-02-13 13:21:09956browse

如何在 Docker 的容器上安装 go-migrate?

Installing go-migrate on Docker containers is a common requirement, which can help us perform database migration in our applications. Installing go-migrate and using it in Docker containers can make our development environment more convenient and flexible. In this article, I will introduce you to the steps and precautions for installing go-migrate on Docker containers. Whether you are a newbie or an experienced developer, this article will provide you with detailed guidance to master this skill with ease. Let’s take a look at how to install go-migrate on a Docker container!

Question content

I'm looking into containers and docker and I'm trying to run a container using go-migrate but I get 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 m1 macbook, 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 option to install install migrate. Since you are using the go image, it will be easier to install like this For example

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

The above is the detailed content of How to install go-migrate on a Docker container?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete