> ## Content Index
> Fetch the complete content index at: https://til.codes/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to install a specific package version in Alpine and Docker?
- URL: https://til.codes/how-to-install-a-specific-package-version-in-alpine-and-docker/
- Published: 2016-05-09T16:34:00.000Z
- Updated: 2016-12-16T06:10:20.000Z
- Author: Manu Ajith
- Tags: docker, linux, til, #Import 2024-07-13 21:01

I was building a docker image for a backend API application that I was working on, so that my colleague, who is a front-end guy can easily setup the docker container and get it up and running.

I chose Alpine Linux to build the Docker image bcos its light weight. I started adding dependencies to the Dockerfile and I came across a situation where I needed to use a specific version of the package.

So this was what I had in my Dockerfile:

```
RUN apk update && \
    apk upgrade && \
    apk add ruby

```

And I needed Ruby 2.2.4 version to be installed in the image.

With the above code, it installs the latest version of the Ruby which is 2.3.

After some googling, I figured out that we can specify the version and lock it down so that the package manager will use that specific version of the package.

So here is the same code now:

```
RUN apk update && \
    apk upgrade && \
    apk add ruby=2.2.4

```

Exploring the options, we can set a minimum or maximum version to any package using

```
apk add 'packagename<1.2.3-suffix'

```

or

```
apk add 'packagename>1.2.3-suffix'

```

Hope this helps someone or even me in future. :)