9
4

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.

Docker for MacでAmazon Linux 2でsystemd

Posted at

EC2 上の Amazon Linux 2 は systemd を使いますが、Docker Hub にある amazonlinux 公式イメージ https://hub.docker.com/_/amazonlinux/ のデフォルト状態では systemd が利用できません。

Dockerfile

FROM amazonlinux:2
RUN yum -y update && yum -y install procps systemd-sysv
CMD ["/sbin/init"]

docker-compose.yml

version: "2"

services:
  amzn:
    build: "."
    cap_add:
      - SYS_ADMIN
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro

このほかに privileged: truesecurity_opt: - seccomp:unconfined が必要という記事もみかけますが、現在は不要になっているようです。(2019年6月現在)

また、Mac 本体には /sys/fs/cgroup は存在しませんが、こちらも問題ないようです。

以下のように起動できます。

docker-compose build
docker-compose up -d
docker-compose exec amzn bash
docker-compose exec amzn systemctl -all
docker-compose exec amzn journalctl -f

systemctl や journalctl が使えるようになりました。

9
4
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
9
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?