3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laradockのworkspaceの開始で PermissionError: [Errno 13] Permission denied: '/etc/container_environment' になる

Last updated at Posted at 2018-11-26

Dockerをインストール

こちらより Docker Community Edition for Mac をダウンロード
https://www.docker.com/

Dockerをインストールし、起動、開始します。

作業ディレクトリの作成

$cd ~
$mkdir laravel
$cd laravel

Laradockをclone

$git clone https://github.com/Laradock/laradock.git
Cloning into 'laradock'...
remote: Enumerating objects: 8276, done.
remote: Total 8276 (delta 0), reused 0 (delta 0), pack-reused 8276
Receiving objects: 100% (8276/8276), 7.83 MiB | 1.62 MiB/s, done.
Resolving deltas: 100% (4384/4384), done.
Checking out files: 100% (241/241), done.

laradockディレクトリに移動し、env-exampleを.envにコピー

$cd laradock
$cp env-example .env

workspaceコンテナを作成

$docker-compose up -d workspace

しばらく待ちます。

コンテナ作成の確認

docker-compose ps
                  Name                            Command          State     Ports  
------------------------------------------------------------------------------------
laradock_docker-in-docker_1_514e83e0ed6d   dockerd-entrypoint.sh   Up       2375/tcp
laradock_workspace_1_580a89aaa428          /sbin/my_init           Exit 1     

コンテナの起動

$docker-compose up workspace
laradock_docker-in-docker_1_514e83e0ed6d is up-to-date
Starting laradock_workspace_1_580a89aaa428 ... done
Attaching to laradock_workspace_1_580a89aaa428
workspace_1_580a89aaa428 | *** Killing all processes...
workspace_1_580a89aaa428 | Traceback (most recent call last):
workspace_1_580a89aaa428 |   File "/sbin/my_init", line 417, in <module>
workspace_1_580a89aaa428 |     main(args)
workspace_1_580a89aaa428 |   File "/sbin/my_init", line 333, in main
workspace_1_580a89aaa428 |     import_envvars(False, False)
workspace_1_580a89aaa428 |   File "/sbin/my_init", line 90, in import_envvars
workspace_1_580a89aaa428 |     for envfile in listdir("/etc/container_environment"):
workspace_1_580a89aaa428 |   File "/sbin/my_init", line 74, in listdir
workspace_1_580a89aaa428 |     return sorted(os.listdir(path))
workspace_1_580a89aaa428 | PermissionError: [Errno 13] Permission denied: '/etc/container_environment'
laradock_workspace_1_580a89aaa428 exited with code 1

起動しません…。

workspaceのDockerfileを修正し、ビルド

エラーの原因は、laradockの不具合にあるようです。
(以前はそのままworkspaceを起動できたので)
https://github.com/laradock/laradock/issues/1889
このページの記載の通りにやってみます。

$cd workspace
$vi Dockerfile
USER laradock

この部分を、

USER root

このように直します。

workspaceコンテナをビルドします。

$docker-compse build workspace

もう一度起動したら正常に起動できました。

$docker-compose up workspace
laradock_docker-in-docker_1_572d1ac3827f is up-to-date
Recreating laradock_workspace_1_232710d67434 ... done
Attaching to laradock_workspace_1_232710d67434
workspace_1_232710d67434 | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
workspace_1_232710d67434 | *** Running /etc/my_init.d/10_syslog-ng.init...
workspace_1_232710d67434 | Nov 26 15:37:53 1cb4158c931a syslog-ng[10]: syslog-ng starting up; version='3.5.6'
workspace_1_232710d67434 | Nov 26 15:37:53 1cb4158c931a syslog-ng[10]: WARNING: you are using the pipe driver, underlying file is not a FIFO, it should be used by file(); filename='/dev/stdout'
workspace_1_232710d67434 | Nov 26 15:37:54 1cb4158c931a syslog-ng[10]: EOF on control channel, closing connection;
workspace_1_232710d67434 | *** Running /etc/rc.local...
workspace_1_232710d67434 | *** Booting runit daemon...
workspace_1_232710d67434 | *** Runit started as PID 16
workspace_1_232710d67434 | Nov 26 15:37:54 1cb4158c931a cron[19]: (CRON) INFO (pidfile fd = 3)
workspace_1_232710d67434 | Nov 26 15:37:54 1cb4158c931a cron[19]: (CRON) INFO (Running @reboot jobs)
Killing laradock_workspace_1_232710d67434    ... done

この件、最初はworkspaceの起動でデタッチドモード(-d)でやっていたため、エラーに気づくまで時間がかかってしまいました。
このように起動すると、エラー内容が出力されないため不具合に気づきにくくなります。

$docker-compose up -d workspace

オプションなしのアタッチドモードで起動すれば、ログが吐き出され続けるので状態の把握がしやすくなるようです。
(この場合、同じシェルウインドウでは作業ができなくなりますが…)

$docker-compose up workspace
Starting laradock_docker-in-docker_1_572d1ac3827f ... done
Starting laradock_workspace_1_232710d67434        ... done
Attaching to laradock_workspace_1_232710d67434
workspace_1_232710d67434 | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
workspace_1_232710d67434 | *** Running /etc/my_init.d/10_syslog-ng.init...
workspace_1_232710d67434 | Nov 27 14:59:04 1cb4158c931a syslog-ng[9]: syslog-ng starting up; version='3.5.6'
workspace_1_232710d67434 | Nov 27 14:59:04 1cb4158c931a syslog-ng[9]: WARNING: you are using the pipe driver, underlying file is not a FIFO, it should be used by file(); filename='/dev/stdout'
workspace_1_232710d67434 | Nov 27 14:59:05 1cb4158c931a syslog-ng[9]: EOF on control channel, closing connection;
workspace_1_232710d67434 | *** Running /etc/rc.local...
workspace_1_232710d67434 | *** Booting runit daemon...
workspace_1_232710d67434 | *** Runit started as PID 15
workspace_1_232710d67434 | Nov 27 14:59:05 1cb4158c931a cron[18]: (CRON) INFO (pidfile fd = 3)
workspace_1_232710d67434 | Nov 27 14:59:05 1cb4158c931a cron[18]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?