How to install go-migrate on a Docker container?

WBOY
Release: 2024-02-13 13:21:09
forward
966 people have browsed it

如何在 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
Copy after login

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
Copy after login

Solution

There is also an option to install< /a> 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
Copy after login

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template