linuxoraclelinux

How to install vim on Oracle Linux Server 8.7?


I have a docker-container running MySQL, which is based on the image mysql:8, which is managed by the following docker-compose.yml:

version: '3.5'

services:

  db:
    image: mysql:8
    environment:
      - MYSQL_ROOT_PASSWORD=xxx
      - MYSQL_DATABASE=xxx
      - MYSQL_USER=xxx
      - MYSQL_PASSWORD=xxxs3cr3t
      - MYSQL_TCP_PORT=3310
      - TZ=Europe/Berlin
    ports:  # for developer machines only!
      - "3310:3310"
    volumes:
      - mysql:/var/lib/mysql

I want to bash into this container and modify the my.cnf-file using an Editor like VIM.

So I exec into the bash of the container:

docker exec -it 4be bash

and try to modify the my.cnf file.

Unfortunately, there is no known editor installed: no vim, no vi, no nano. There is also no package manager installed like apt-get or yum or dnf installed.

According to the command cat /etc/*-release (at least cat is available), it seems to be an "Oracle Linux Server release 8.7"

I've never heard of that kind of Linux distribution.

How can I install an editor to modify the my.cnf-file?


Solution

  • There is always a chance that sed is installed which would allow you to edit the file in place (though non-interactively).

    The most pracitcable solution might be to copy the file from the container to the host, edit the file with the tools available on the host, then copy the edited file back to the host.

    docker cp <container>:/path/to/my.cnf .
    <edit the file using vim/emacs/etc on host os>
    docker cp my.cnf <container>:/path/to/my.cnf
    

    https://docs.docker.com/engine/reference/commandline/cp/