Skip to content

Simple setting to dealing with Dockerfile and docker-compose

License

Notifications You must be signed in to change notification settings

sumer5020/docker-setting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Setting

Simple setting to dealing with Dockerfile and docker-compose

Install Docker

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    Lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Basic Docker Commands

  1. how to search a docker image in hub.docker.com
docker search httpd
  1. Download a docker image from hub.docker.com
docker image pull <image_name>:<image_version/tag>
  1. Show all docker images on your local system
docker image
  1. Build docker image from Dockerfile
docker build -t <image_name> . #the dot in the end specify the current directory where the Dockerfile is located 
  1. Create a docker container from image
docker run --name <container_Name> <image_name>:<image_version/tag>

docker - run your container in back ground (detached)
 
docker run -d --name <container_Name> <image_name>:<image_version/tag>
  1. Expose your application to host server
docker run -d --name <container_Name> -p <host_port>:<container_port> <image_name>:<Image_version/tag>

docker run -d --name httpd_container -p 8080:80 httpd:latest
  1. Show all running containers
docker ps
  1. Show all docker container (running, stpooed, terminated, etc...)
docker ps -a
  1. Get inside a container
docker exec -it <container_Name> bash
  1. Stop a container
docker stop <container_id>
  1. Start a container which is stopped
docker start <container_id>
  1. Remove a container
docker rm <container_id>
  1. Remove docker image
docker rmi <image_id>

Dockerfile

Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

Docker compose

Docker compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration.

About

Simple setting to dealing with Dockerfile and docker-compose

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published