1.

Create a docker file and build a new image. Run the image and create a container.

Answer» FROM divyabhushan/myrepo:latest COPY HELLO.sh /home/hello.sh CMD ["bash", "/home/hello.sh"] CMD ["echo", "Dockerfile demo"] RUN echo "dockerfile demo" >> logfile

--Build an image from the dockerfile, tag the image name as ‘mydocker’

docker build -t mydocker dockerFiles/ docker build --tag <containerName> <dockerfile location> Divya1@DIVYA:~ $docker images REPOSITORY            TAG IMAGE ID            CREATED SIZE mydocker              latest aacc2e8eb26a        20 seconds ago 88.1MB Divya1@Divya:~ $docker run mydocker /home/divya Hello Divya Bye Divya
  • View the images:
  • docker image
  • docker image --all
  • docker run -it ubuntu (imageName)
  • -i = interactive
  • -t = Allocate a sudo-tty (i.e, PROVIDE a terminal for the remote container image)


Discussion

No Comment Found