# WorkShop 2022/12/13 ### Basic Command ```shell= docker version docker --help ``` --- ### Build Command ```shell= docker image build . # or docker image build -t REPOSITORY:latest . # or docker image build -f ./Dockerfile . ``` --- ### Tips #### .dockerignore ```shell= node_modules ``` #### COPY VS ADD ```shell= COPY . . ADD my_big_lib.tar.gz /var/lib/myapp ADD http://aaaaa/my_big_lib.tar.gz /var/lib/myapp ``` ### Build cache ```shell= COPY package*.json . RUN npm i COPY . . ``` --- ### Reference 1. https://docs.docker.com/engine/reference/builder/#usage 2. https://codefresh.io/docker-tutorial/not-ignore-dockerignore-2/ --- ### Get Image ```shell= docker image ls ``` ### Delete Image ```shell= docker image rm IMAGE ID ``` ### Create container ```shell= docker container run -d IMAGE ID docker container run --name=example IMAGE ID ``` ### Watch a running containers ```shell= docker container ls ``` ### Stop a running containers ```shell= docker container stop CONTAINER ID ``` ### Watch all containers ```shell= docker container ls -a ``` ### Delete container ```shell= docker container rm CONTAINER ID ``` --- ### Port-forward ![](https://i.imgur.com/QJVr31I.png) ```shell= docker container run -p 3005:3000 -d IMAGE ID ``` ### Remove all container ```shell= docker container ls -aq | xargs docker container rm -f ``` --- ### Dock login ```shell= docker login ``` ### Docker image add tag ```shell= docker tag REPOSITORY DockerHubAccount/REPOSITORY ``` ### Docker push ```shell= docker push REPOSITORY ``` --- 影片推薦 1. https://www.youtube.com/watchv=WmcdMiyqfZs&ab_channel=TechWorldwithNana
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up