Sign inSign up

hjben/mariadb

By hjben

•Updated over 2 years ago

mariadb image based on centos/rocky, with UTF-8 encoding

Image
0

10K+

hjben/mariadb repository overview

⁠mariadb

⁠Introduction

MariaDB image based on hjben/centos-systemd:latest, with UTF-8 encoding

⁠Usage
⁠1. Pull image
  • Pull docker image from the DockerHub, or build the image with Dockerfile.
  • Docker image tag is related to the version of MariaDB.
    • docker pull hjben/mariadb:{mariadb_version}
    • e.g. docker pull hjben/mariadb:10.11
⁠2. Run container
  • Command to run the MariaDB container is below.
    • docker run --privileged --cgroupns=host --name {container_name} -d -p 3306:3306 -v {host_path_to_save_DB_data}:/var/lib/mysql -v /sys/fs/cgroup:/sys/fs/cgroup:rw -e MARIADB_ROOT_PASSWORD={mariadb_password_you_want} hjben/mariadb:{mariadb_version}
    • e.g. docker run --privileged --cgroupns=host --name mariadb -d -p 3306:3306 -v /Users/Shared/workspace/docker/maria-data:/var/lib/mysql -v /sys/fs/cgroup:/sys/fs/cgroup:rw -e MARIADB_ROOT_PASSWORD=mariadb hjben/mariadb:10.11
  • Command Description
    • -d: Run with daemon (background) mode
    • --privileged: Share the host permission with container
    • --cgroupns=host: Privilege the host's group
    • --name {container_name}: Set container name to {container_name}
    • -v /sys/fs/cgroup:/sys/fs/cgroup:rw: Share the disk volume between host and container, to access host cgroup from the container
    • -p 3306:3306: Expose 3306 port of the container
    • -v {host_path_to_save_DB_data}:/var/lib/mysql: Share the disk volume between host and container, to save the MariaDB data in {host_path_to_save_DB_data}
    • -e MARIADB_ROOT_PASSWORD={mariadb_password_you_want}: Pass the custom mariadb root password to container
⁠3. Start MariaDB service
  • In the container shell, run the command "/sh/init.sh". Then the MariaDB service will be started.
  • If you're in the host shell and not in the container shell, the command below maybe work for you.
    • docker exec {mariadb_container_name} bash -c "/sh/init.sh"
    • e.g. docker exec mariadb bash -c "/sh/init.sh"
  • "/sh/init.sh" contain some linux commands to start the MariaDB service and set root password.
⁠4. Change MariaDB root password
  • If you want to change root password of the database, run the command below in the container shell.
    • /sh/set-root-password.sh {password_to_change}
    • e.g. /sh/set-root-password.sh 1234
  • When in host shell, you're able to execute them with "docker exec" command.
    • docker exec {mariadb_container_name} bash -c "/sh/set-root-password.sh {password_to_change}"
⁠5. Access to DB in container
  • First, you should access the running container.
  • You can access the container by typing the "docker exec" command.
    • docker exec -it {container_name} bash
    • e.g. docker exec -it mariadb bash
  • Login with root account.
    • Run the command below and enter your root password.
    • mysql -u root -p
⁠6. Then, enjoy your MariaDB!

Tag summary

Content type

Image

Digest

sha256:58dce0033…

Size

440 MB

Last updated

over 2 years ago

docker pull hjben/mariadb