1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Docker] コンテナが起動しない時の対応

Posted at

Dockerを使っているとコンテナが起動すらせず、中がどうなっているか確認できないことがある。

# ASP.NET Core 8.0のランタイムイメージを使用
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080

# .NET SDK 8.0を使用してビルド環境を構築
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["ProjectTest.csproj", "./"]
RUN dotnet restore ProjectTest.csproj

# ソースコード全体をコピーし、リリースビルドを実行
COPY . .
RUN dotnet publish -c Release -o /app/publish
ENTRYPOINT ["tail", "-f", "/dev/null"] 

# ランタイムイメージに公開済みビルドをコピー
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "ProjectTest.dll"]

image.png

この場合、ENTRYPOINTを以下のコードに変更する

ENTRYPOINT ["tail", "-f", "/dev/null"] 

コンテナが起動するので、以下のコマンドをターミナルで実行するとコンテナ内に入ることができる

docker exec -it <コンテナID> /bin/bash  
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?