# Docker Note ### Upgrade docker-compose v1 to v2 - Install using the repository ``` sudo apt-get update sudo apt-get install docker-compose-plugin ``` https://docs.docker.com/compose/install/linux/ - Install the plugin manually (Ubuntu 16.04) ``` DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} # create the docker plugins directory if it doesn't exist yet mkdir -p $DOCKER_CONFIG/cli-plugins # download the CLI into the plugins directory curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose # make the CLI executable chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose ``` https://www.rockyourcode.com/how-to-install-docker-compose-v2-on-linux-2021/ https://askubuntu.com/questions/1424118/how-to-install-docker-and-docker-compose-on-ubutntu-22-04 - Check version `docker compose version` ### Useful command - list container `sudo docker ps -a` - list images `sudo docker images` - start/stop container `sudo docker start {CONTAINER ID}` `sudo docker stop {CONTAINER ID}` - remove container `sudo docker rm {CONTAINER ID}` - remove all exited containers `sudo docker rm $( sudo docker ps --filter status=exited -q)` - into container by id `sudo docker exec -it {CONTAINER ID} bash` - run image `sudo docker run -it {REPOSITORY}:{TAG} bash` - run image & mount host directory to container `sudo docker run -v /home/yen/:/tmp -it {REPOSITORY}:{TAG} bash` - export container `sudo docker export {NAMES} | gzip > container_file.gz` - import local file to image `sudo docker import container_file.gz {REPOSITORY}:{TAG}` - save image `sudo docker save {REPOSITORY}:{TAG} > image_file.tar` - load image `sudo docker load < image_file.tar` - build image by dockerfile `sudo docker build -t {REPOSITORY}:{TAG} .` ###### tags: `Note` `Docker`
×
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