Basics
Check installed Docker version.
Show system-wide information about Docker.
Images
List all downloaded images.
Download image from Docker Hub.
Remove an image from your system.
Containers
Show running containers.
Show all containers (running + stopped).
Run Nginx in background on port 8080.
Stop a running container.
Remove a stopped container.
Volumes
List all volumes.
Create a new volume named "myvol".
Run container and mount volume to /data.
Networks
List all Docker networks.
Create a new network named "mynet".
Run container inside "mynet" network.
Docker Compose
Start services in background from compose file.
Stop and remove all services.
List containers managed by compose.
Sample Dockerfiles
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 5000
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["MyApi.csproj", "./"]
RUN dotnet restore "MyApi.csproj"
COPY . .
RUN dotnet build "MyApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyApi.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApi.dll"]
Dockerfile for an ASP.NET Core Web API project.
# Stage 1 - Build Angular App
FROM node:18 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build --prod
# Stage 2 - Nginx server
FROM nginx:alpine
COPY --from=build /app/dist/my-angular-app /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Dockerfile for building and serving Angular with Nginx.
FROM mcr.microsoft.com/mssql/server:2022-latest
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=YourStrong!Passw0rd
EXPOSE 1433
CMD ["/opt/mssql/bin/sqlservr"]
Dockerfile to run SQL Server container.