iT邦幫忙

0

docker-compose 出現 read-only file system 問題

2020-10-06 20:39:099530 瀏覽
  • 分享至 

  • xImage

Hello!大家好 ??

是這樣的,我的環境是新裝的 Ubuntu 18.04,剛剛在使用 docker + docker-compose 起服務的時候一直起不來

我的 docker-compose.yml

version: "3"
services:
  mariadb:
    image: mariadb:10.2.15
    container_name: maria-db
    restart: always
    environment:
        MYSQL_ROOT_PASSWORD: rootpassword
        MYSQL_DATABASE: mydb
        MYSQL_USER: testuser
        MYSQL_PASSWORD: mypassword
    volumes:
      - ./conf:/etc/mysql/conf.d
      - ./data:/var/lib/mysql
      - ./log:/var/log/mysql
      - ./tmp:/tmp
    ports:
      - "127.0.0.1:30403:3306"

一開始的問題是這樣:

$ docker-compose up -d

ERROR:
        Can't find a suitable configuration file in this directory or any
        parent. Are you in the right directory?

        Supported filenames: docker-compose.yml, docker-compose.yaml

但是我反覆確定,我目錄下確實有 docker-compose.yml 這個檔案

不過這個問題還好解,我重新下載一次 docker-compose 就好了 ??

$ sudo apt install docker-compose

但是之後的問題就比較玄了!我再試著叫起服務的時候他給我這樣的訊息

# 當我再從執行 docker-compose 叫起服務的時候
$ docker-compose up -d
Starting maria-db ...
Starting maria-db ... error

ERROR: for maria-db  Cannot start service mariadb: error while creating mount source path '/data/wayne/dockers/maria-db/tmp': mkdir /data: read-only file system

ERROR: for mariadb  Cannot start service mariadb: error while creating mount source path '/data/wayne/dockers/maria-db/tmp': mkdir /data: read-only file system
ERROR: Encountered errors while bringing up the project.

我同樣確定很多次我的目錄權限是沒錯的,Owner、Group 也都沒有設定錯誤,但怎麽執行就是一直錯

我試過這個方法,執行 docker-compose down 再 docker-compose up 還並不管用…

# 把 docker-compose 服務下下來
$ docker-compose down
Removing maria-db ... done
Removing network mariadb_default

# 再打開
$ docker-compose up
Creating network "mariadb_default" with the default driver
Creating maria-db ...
Creating maria-db ... error

ERROR: for maria-db  Cannot start service mariadb: error while creating mount source path '/data/wayne/dockers/maria-db/log': mkdir /data: read-only file system

ERROR: for mariadb  Cannot start service mariadb: error while creating mount source path '/data/wayne/dockers/maria-db/log': mkdir /data: read-only file system
ERROR: Encountered errors while bringing up the project.

這樣還是一樣的錯誤 read-only file system 這樣

最後我還是有試出成功的解法 是 systemctl stop docker 再 start 起來就好了...

# 先把 docker 服務關掉
$ systemctl stop   docker
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop 'docker.service'.
Authenticating as: wayne
Password:
==== AUTHENTICATION COMPLETE ===


# 再打開
$ systemctl start   docker
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'docker.service'.
Authenticating as: wayne
Password:
==== AUTHENTICATION COMPLETE ===

# 就有點莫名其妙的好了...
$ docker-compose up -d
Creating network "mariadb_default" with the default driver
Pulling mariadb (mariadb:10.2.15)...
10.2.15: Pulling from library/mariadb
3d77ce4481b1: Pull complete
f79b1d6f55d8: Pull complete
20581e7b5d1e: Pull complete
e585456bc466: Pull complete
bead064b3a08: Pull complete
66590767e853: Pull complete
8e314a33356b: Pull complete
01f025d1f950: Pull complete
adb4938fde68: Pull complete
aec4051fe292: Pull complete
5acf49ed93c9: Pull complete
version: "3"
Digest: sha256:6e5ede826eedd0a8126e1d9249a281ce39e57c7c9118a4cf300437566d5e1863
Status: Downloaded newer image for mariadb:10.2.15
Creating maria-db ...
Creating maria-db ... done

當然!我的服務起來了我很高興,只是這樣用起來抖抖的,實在有點想知道到底發生了什麼事,請問有大大可以提點一下嗎~ 謝謝

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
ifurther
iT邦新手 4 級 ‧ 2022-06-25 00:44:52

連結中的user可以設定系統使用者,可以使用看看

我要發表回答

立即登入回答