YugabyteDB official Dockerfile
Tags: yugabytedb, distributed, sql, docker
Published: 2023-08-11 14:16:16

You have seen me using the [official YugabyteDB Docker](https://hub.docker.com/r/yugabytedb/yugabyte) image extensively. This image is suitable for various purposes, including labs, development, testing, and even production. In the past, we used to create it internally due to its seamless integration with our build process. However, some companies prefer to construct the image on their own, which is indeed a commendable practice. After all, it's not advisable to run random images with root privileges on your servers. As a result, we have made a significant alteration by introducing a refined [Dockerfile](https://github.com/yugabyte/yugabyte-db/blob/master/docker/images/yugabyte/Dockerfile) to our Github repository.

Here's how I obtain the command to download the latest preview:
```sh
curl -Ls https://docs.yugabyte.com/preview/quick-start/linux/ |
 awk -F">" "/wget.*$(uname -m)/"'{sub(/wget/,"wget -c");print $NF}'

```
You can also acquire the desired version from [the download page](https://download.yugabyte.com/#/linux)

Subsequently, I retrieve the YugabyteDB source repository, download the release, and proceed to build the Docker image:
```sh

git clone https://github.com/yugabyte/yugabyte-db.git /var/tmp/yugabytedb
cd /var/tmp/yugabytedb/docker/images

# download the release from https://download.yugabyte.com/#linux
wget -c https://downloads.yugabyte.com/releases/2.19.0.0/yugabyte-2.19.0.0-b190-el8-aarch64.tar.gz
./build_docker.sh -f $(basename $_)

```
If you utilize `podman` you can execute the same process by installing the `podman-docker` package (`sudo dnf install -y podman-docker`) to replace Docker commands with Podman equivalents. However, please note that the image requires certain root permissions, necessitating the command `sudo ./build_docker.sh` to be executed.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1z1fu2ei7oa2ie1tsa37.png)

I haven't assigned a name to my image since this is merely a test. Nonetheless, I am able to run a container from it and perform YugabyteDB testing:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qel5n40se7hp8qibyq6c.png)

I can execute the identical steps using my repository name (`-r pachot`), incorporate the architecture into the version tag (`-a`) and apply the Docker option to consolidate all layers into a single layer (`--squash-all`):

```sh
sudo ./build_docker.sh -f yugabyte-2.19.0.0-b190-el8-aarch64.tar.gz -r pachot -a -l -- --squash-all

```

The provided command initiates the following sequence: `docker buildx build --build-arg VERSION=2.19.0.0-b190 --build-arg RELEASE=190-aarch64 --tag pachot/yugabyte:2.19.0.0-b190-aarch64 --output type=docker --squash-all .`

Here is my image:
```
$ sudo docker images

Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
REPOSITORY                   TAG                    IMAGE ID      CREATED        SIZE
docker.io/pachot/yugabyte    2.19.0.0-b190-aarch64  18062b19e188  5 minutes ago  1.92 GB
docker.io/pachot/yugabyte    latest                 18062b19e188  5 minutes ago  1.92 GB
docker.io/library/almalinux  8                      554a0aef23e4  3 weeks ago    218 MB
```