3
2

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.

CodeBuildでDocker in Dockerする(CloudFormation)

Posted at

やり方

CodeBuild Project > Environment > PrivilegedModeをTrueにする

PrivilegedMode:
プロジェクトで Docker イメージを実行する方法を示します。true を指定して、Docker コンテナ内の Docker デーモンを実行できるようにします。
AWS CodeBuild プロジェクト環境

Before

  CodeBuildProject:
    Description: Creating AWS CodeBuild project
    Type: AWS::CodeBuild::Project
    Properties:
      Artifacts:
        Type: CODEPIPELINE
      Description: !Sub Building stage for ${Branch}.
      Environment:
        ComputeType: BUILD_GENERAL1_SMALL
        EnvironmentVariables:
          - Name: Branch
            Value: !Ref Branch
        Image: !Ref CodeBuildImage
        Type: LINUX_CONTAINER
      Name: !Sub ${ServiceName}-${Branch}-build
      ServiceRole: !Ref CodeBuildRole
      Source:
        Type: CODEPIPELINE
      TimeoutInMinutes: 5

After

  CodeBuildProject:
    Description: Creating AWS CodeBuild project
    Type: AWS::CodeBuild::Project
    Properties:
      Artifacts:
        Type: CODEPIPELINE
      Description: !Sub Building stage for ${Branch}.
      Environment:
        ComputeType: BUILD_GENERAL1_SMALL
        EnvironmentVariables:
          - Name: Branch
            Value: !Ref Branch
        Image: !Ref CodeBuildImage
        Type: LINUX_CONTAINER
        PrivilegedMode: True
      Name: !Sub ${ServiceName}-${Branch}-build
      ServiceRole: !Ref CodeBuildRole
      Source:
        Type: CODEPIPELINE
      TimeoutInMinutes: 5

エラー

上記の指定をしないと↓のエラーが出る。

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

備考

3
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?