Git Product home page Git Product logo

inception's Introduction

Inception

This project aims to broaden your knowledge of system administration by using Docker. You will virtualize several Docker images, creating them in your new personal virtual machine.

inception's People

Contributors

kimhxsong avatar

Watchers

 avatar

inception's Issues

Additional property {property} is not allowed

docker-compose.yml

wordpress:
    image: wordpress
    links:
     - mariadb:mysql
    environment:
     - WORDPRESS_DB_PASSWORD=password
     - WORDPRESS_DB_USER=root
    ports:
     - "public_ip:80:80"
    volumes:
     - ./html:/var/www/html
mariadb:
    image: mariadb
    environment:
     - MYSQL_ROOT_PASSWORD=password
     - MYSQL_DATABASE=wordpress
    volumes:
     - ./database:/var/lib/mysql

https://upcloud.com/resources/tutorials/deploy-wordpress-with-docker-compose

A problem situation

(main)⚡ % docker-compose up -d                                                                                                                             ~/Dev/Inception
(root) Additional property mariadb is not allowed

ERROR 1064 (42000): ... for the right syntax to use near 'password("")' at line 1

MariaDB Info

(main)⚡ % mariadb --version                           ~/Inception/srcs/mariadb
mariadb  Ver 15.1 Distrib 10.8.3-MariaDB, for osx10.17 (arm64) using  EditLine wrapper

Error

(main)⚡ [1] % mysql -uroot                            ~/Inception/srcs/mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 8.0.29 Homebrew

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> set password for 'root'@'localhost' = password("");
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'password("")' at line 1
MySQL [(none)]>

Example
For example, if you had an entry with User and Host column values of 'bob' and '%.loc.gov', you would write the statement like this:

SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');

If you want to delete a password for a user, you would do:

SET PASSWORD FOR 'bob'@localhost = PASSWORD("");

Reference: https://mariadb.com/kb/en/set-password/

Solved

(main)⚡ % mysql -uroot
MySQL [(none)]> alter user 'root'@'localhost' identified with mysql_native_password by 'db1234';
Query OK, 0 rows affected (0.006 sec)

MySQL [(none)]> exit
Bye
(main)⚡ % mysql -uroot -pdb1234                       ~/Inception/srcs/mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 8.0.29 Homebrew

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>

To change the root password, type the following at the MySQL/MariaDB command prompt:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyN3wP4ssw0rd';
flush privileges;
exit;

Reference: Configuring a default root password for MySQL/MariaDB

ERROR [internal] load metadata for docker.io/library/...

Error

(main)⚡ % docker build -t test .                      ~/Inception/srcs/mariadb
[+] Building 1.1s (3/3) FINISHED
 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 122B                                       0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => ERROR [internal] load metadata for docker.io/library/ubuntu:20.04      1.0s
------
 > [internal] load metadata for docker.io/library/ubuntu:20.04:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``

Solved

(main)⚡ % cat ~/.docker/config.json                   ~/Inception/srcs/mariadb
{
  "auths": {
    "https://index.docker.io/v1/": {}
  },
  "credsStore": "desktop"
}
vi ~/.docker/config.json

// credsStore -> credStore

(main)⚡ % cat ~/.docker/config.json                   ~/Inception/srcs/mariadb
{
  "auths": {
    "https://index.docker.io/v1/": {}
  },
  "credStore": "desktop"
}

nginx: invalid option: "off"

docker-entrypoint.sh

#!/bin/bash

exec nginx -g daemon off
(main2)⚡ % docker logs nginx --tail 50 -f                                                                                                           ~/Dev/Inception
nginx: invalid option: "off"
nginx: invalid option: "off"
nginx: invalid option: "off"
nginx: invalid option: "off"
nginx: invalid option: "off"
nginx: invalid option: "off"
nginx: invalid option: "off"
nginx: invalid option: "off"

Error: Cannot install mariadb because conflicting formulae are installed.

Error

% brew install mariadb
Error: Cannot install mariadb because conflicting formulae are installed. 
  mysql: because mariadb, mysql, and percona install the same binaries    
                                                                          
Please `brew unlink mysql` before continuing.                             
                                                                          
Unlinking removes a formula\'s symlinks from /opt/homebrew. You can        
link the formula again after the install finishes. You can --force this   
install, but the build may fail or cause obscure side effects in the      
resulting software. 

Solved

[1] % brew unlink mysql
Unlinking /opt/homebrew/Cellar/mysql/8.0.29... 98 symlinks removed.       
% brew install mariadb 

flags: 0x1000: no such file or directory

version: '3.9'

services:
  mariadb:
    image: mariadb:myapp
    build: ./mariadb
    container_name: mariadb
    restart: unless-stopped
    env_file: .env
    networks:
      - back-tier
    expose:
      - 3306
    volumes:
      - db-data:/var/lib/mysql

networks:
  back-tier:

volumes:
  db-data:
    driver_opts:
      type: none
      device: ${HOME}/${USER}/data/db
      o: bind
inception-2 docker-compose up    
[+] Running 0/1
 ⠿ mariadb Error                                                                                                                                                                         2.4s
[+] Building 1.9s (7/7) FINISHED                                                                                                                                                              
 => [internal] load build definition from Dockerfile                                                                                                                                     0.0s
 => => transferring dockerfile: 32B                                                                                                                                                      0.0s
 => [internal] load .dockerignore                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/debian:buster                                                                                                                         1.9s
 => [1/3] FROM docker.io/library/debian:buster@sha256:e5b41ae2b4cf0d04b80cd2f89724e9cfc09e334ac64f188b9808929c748af526                                                                   0.0s
 => => resolve docker.io/library/debian:buster@sha256:e5b41ae2b4cf0d04b80cd2f89724e9cfc09e334ac64f188b9808929c748af526                                                                   0.0s
 => CACHED [2/3] RUN set -ex;     apt-get update;     apt-get install -y --no-install-recommends mariadb-server                                                                          0.0s
 => CACHED [3/3] RUN mysql_install_db                                                                                                                                                    0.0s
 => exporting to image                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                  0.0s
 => => writing image sha256:fe0ff2a2db75aff89c8ccdb0b6124f676de917dcd109ccbd72cefe37e2079a6d                                                                                             0.0s
 => => naming to docker.io/library/mariadb:myapp                                                                                                                                         0.0s
[+] Running 0/0
 ⠋ Container mariadb  Creating                                                                                                                                                           0.0s
Error response from daemon: failed to mount local volume: mount /home/hyeonsok/data/db:/mnt/sda1/var/lib/docker/volumes/inception-2_db-data/_data, flags: 0x1000: no such file or directory

[ERROR] Can't start server : Bind on unix socket: No such file or directory

문제 상황 : 컨테이너가 mysqld을 실행하면 에러를 반환하고 종료됨

Dockerfile

FROM ubuntu:20.04

RUN apt-get update
RUN apt-get install -y mariadb-server

EXPOSE 3306

LABEL version="1.0"
LABEL description="MariaDB Server"

HEALTHCHECK --start-period=5m \
  CMD mariadb -e 'SELECT @@datadir;' || exit 1

CMD ["mysqld"]

참고: https://mariadb.com/kb/en/creating-a-custom-docker-image/#dockerfile-syntax

Container Statuses

(main)⚡ % docker ps -a                                                              ~/Inception/srcs/mariadb
CONTAINER ID   IMAGE       COMMAND                  CREATED          STATUS                      PORTS                  NAMES
683b315db4da   test        "mysqld"                 14 seconds ago   Exited (1) 11 seconds ago                          zen_agnesi
...

=> 커맨드 실행 직후 종료

Checking what arguments a local mysqld was run with

bash-3.2$ ps -e | grep mysqld
11959 ??         0:00.04 /bin/sh /opt/homebrew/opt/mysql/bin/mysqld_safe --datadir=/opt/homebrew/var/mysql
12127 ??         1:18.54 /opt/homebrew/opt/mysql/bin/mysqld --basedir=/opt/homebrew/opt/mysql --datadir=/opt/homebrew/var/mysql --plugin-dir=/opt/homebrew/opt/mysql/lib/plugin --log-error=SSONGui-MacBookAir.local.err --pid-file=SSONGui-MacBookAir.local.pid
 3686 ttys001    0:00.00 grep mysqld

mysqld options

-b, --basedir=name

  • Path to installation directory. All paths are usually resolved relative to this

-h, --datadir=name

  • Path to the database root directory

--plugin-dir=name

  • Directory for plugins

--log-error[=name]

  • Log errors to file (instead of stdout). If file name is not specified then 'datadir'/'log-basename'.err or the

--pid-file=name

  • Pid file used by safe_mysqld

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.