Difference between revisions of "Docker"

From John Freier
Jump to: navigation, search
Line 3: Line 3:
 
== Docker File ==
 
== Docker File ==
  
 +
'''ARG'''
 +
These are arguments that can be used in side the docker file.
 +
  ARG BASE_DIR=/opt/app
 +
  ...
 +
  COPY ./file.txt $BASE_DIR
 +
 +
'''Port'''
 +
To expose port to docker to be exposed, lol kind of redundant.
 +
  EXPOSE 4000
  
 
== Docker Images ==
 
== Docker Images ==
Line 17: Line 26:
 
   docker rmi -f {imagename}:{tag}
 
   docker rmi -f {imagename}:{tag}
  
""Run""
+
'''Run'''
 
This is how you run an image
 
This is how you run an image
 
   docker run -it {imagename}:{tag}
 
   docker run -it {imagename}:{tag}
  
To open the ports
+
To open the ports. Make sure you do this and have the ports exposed in your Dockerfile.
 
   docker run -p 8080:8080 -it {imagename}:{tag}
 
   docker run -p 8080:8080 -it {imagename}:{tag}
  

Revision as of 14:46, 6 September 2019

This is a page all about Docker and helpful commands.

Docker File

ARG These are arguments that can be used in side the docker file.

 ARG BASE_DIR=/opt/app
 ...
 COPY ./file.txt $BASE_DIR

Port To expose port to docker to be exposed, lol kind of redundant.

  EXPOSE 4000

Docker Images

List This will show a list of all docker images.

 docker images

Remove This will remove an image from the list.

 docker rmi {imagename}:{tag}

You might need to force it.

 docker rmi -f {imagename}:{tag}

Run This is how you run an image

 docker run -it {imagename}:{tag}

To open the ports. Make sure you do this and have the ports exposed in your Dockerfile.

 docker run -p 8080:8080 -it {imagename}:{tag}

To run the image in a detacted container for it run in the background.

 docker run -d -it {imagename}:{tag}

To run an image and go right into bash for the starting point.

 docker run -it --entrypoint "/bin/bash" {imagename}:{tag}

To get into bash for a container.

 docker exec -it <container id> /bin/bash