Docker Port

04/01/2022   Docker

Docker Port

- docker run -it -p 9000:80 ubuntu
=> -p (publish a container's ports to the host)
=> host port: 9000; connect: container port: 80
=> install nginx: apt-get update && apt-get install nginx - y && service nginx start
=> can access: http://localhost:9000

- docker run -i -t -p 9000:80 -d ubuntu  
== - docker run -i -t -p 9000:80 ubuntu + -d (Run container in background and print container ID)
=> - docker run -p 9000:80 -d ubuntu  (-i -t  no need bc -d mean run container in background)

- docker exec containerId apt-get update
- docker exec containerId apt-get install nginx -y
- docker exec containerId apt-get start nginx
=> exce (run a command in a running container)

- docker run -it -d -p 9000:80 ubuntu  
=> run container ubuntun in background and connect host port 9000 to container port 80


Bài viết cùng chủ đề