wuping2004 / doc

1 stars 0 forks source link

Docker Container Command #8

Open wuping2004 opened 3 years ago

wuping2004 commented 3 years ago

https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon

///Switch to Linux engine &"$($env:ProgramFiles)\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine

//// login ACR (Repository)

• docker login mytrialcontainerreg-microsoft.azurecr.io

• docker login // log into docker hub

• docker logs f654f9b31c8c

//List docker Images • Docker images

// Login to docker registry

docker login -u -p

docker image pull prasadker/springboot

docker pull /:

PS C:\Users\piw\desktop\DockerImage> docker tag helloworldapp:latest wuping2004/helloworldapp:latest PS C:\Users\piw\desktop\DockerImage> docker push wuping2004/helloworldapp:latest

// list containers

• docker container ps -a

• docker container ls -f 'status=exited' -f 'status=dead'

• docker exec -it [docker container id]  powershell

/// run docker image as container (Start container from a image)

$ docker run -i -t ubuntu:12.04 /bin/bash

$ docker run -it harryzsh/shz_firstcontainer:v1 powershell (I think -i -t is same as -it)

docker run -d -p 999:80 harryzsh/shz_firstcontainer:v1 // 999 is the host port and 80 the container port

docker run -d -p 999:80 harryzsh/shz_firstcontainer:v1 --entrypoint=powershell

// Execute docker container by interaction mode and you can use different tools like powershell or cmd (When container is up and running)

docker exec microsoft/iis:nanoserver bash -c 'echo"$ENV_VAR"'

docker exec -it sh docker exec -it /bin/sh docker exec -it cmd

docker exec -it powershell

// Docker stop container

Docker stop

//Start container

Docker container start Docker start

// Docker remove container

Docker rm

//Docker remove files

docker rm df -f

docker rm ef -f

//Docker remove images

docker rmi c89bd72b9587

docker rm c89bd72b9587

docker image prune -a // remove all images

//Inspect docker container

Docker inspect {containerId} -f "{{.LogPath}}"

Docker inspect {ContainerId} -f "{{json .State.Health}}"

docker inspect 5a

//Container Log

docker logs

docker logs >> "log path" // save to log path

Docker log -- follow // real time logs

Docker log -f // real time logs

Directory of C:\ProgramData\docker\containers{containerId}\log

/var/lib/docker/containers//-json.log

/// container health

Docker stats

///shows all the docker info

docker info

//Copy Files from Docker Container to host

docker cp :\app\mycapture.cap /users/tehnoonr/desktop/theraza

Example:

4 docker login -u wuping2004 -p xxxxxxxxxx 5 docker build -t wuping2004/helloworldapp:v1 -f ./Dockerfi 6 docker build --help 7 docker build -t wuping2004/helloworldapp:v1 -f ./Dockerfi 8 docker ps 9 docker images 10 docker build -t wuping2004/helloworldapp:v2 -f ./Dockerfi 11 docker push wuping2004/helloworldapp:v2

Save Container as image For windows contianer, it needs stop container first. docker stop docker commit repository/name:tag docker login docker push iamge/name:tag
http://www.ntweekly.com/2017/01/16/part-7-save-windows-container-a-docker-image/