Search code examples
mysqldocker-composeyumdnf

How can I disable line wrap in the official MySQL Docker image CLI?


Query results with many columns are difficult to read when the width surpasses the size of your screen and the lines wrap and stack under each other. A common solution to this issue is the use of a pager, like Less or More, but the Docker MySQL image does not come with a pager, nor does it come with the command line tools to install a pager.

I've tried to install the pagers less and more using a variety of package installers, and none of them have worked on the command line:

bash-4.4# yum install less
bash: yum: command not found

bash-4.4# apt-get install less
bash: apt-get: command not found

bash-4.4# dnf install less
bash: dnf: command not found

Is there a way to install Less with the official Docker MySQL image, or at least get a package manager so I can install it myself?

Here is a link to the MySQL Docker image I'm using.


Solution

  • If we look at the image with podman inspect (or docker inspect or any other container image inspection) we see:

              "Labels": null,
              "Annotations": {
                   "com.docker.official-images.bashbrew.arch": "amd64",
                   "org.opencontainers.image.base.digest": "sha256:94e5211ff5e083086ab82506121da739752da964a8d7a1ba98624dc7ac68c76f",
                   "org.opencontainers.image.base.name": "oraclelinux:9-slim",
    
    ....
                   {
                        "created": "2024-07-22T22:36:10Z",
                        "created_by": "RUN /bin/sh -c set -eux; \tmicrodnf install -y \"mysql-community-server-minimal-$MYSQL_VERSION\";
    

    So oraclelinux:9-slim is the base and microdnf is the package installer.

    Is it possible to install less with it?

    $ podman run --rm  mysql microdnf install less
    Downloading metadata...
    Downloading metadata...
    Downloading metadata...
    Downloading metadata...
    Package                  Repository            Size
    Installing:                                        
     less-590-4.el9_4.x86_64 ol9_baseos_latest 179.3 kB
    Transaction Summary:
     Installing:        1 packages
     Reinstalling:      0 packages
     Upgrading:         0 packages
     Obsoleting:        0 packages
     Removing:          0 packages
     Downgrading:       0 packages
    Downloading packages...
    Running transaction test...
    Installing: less;590-4.el9_4;x86_64;ol9_baseos_latest
    Complete.
    

    Yes it is.