docker build .
run
docker build -f Dockerfile.dev .
-ftells we are using a custom file..the dot at the end means the build context(current directory)
Copy path-to-local-file-system path-to-copy-stuff-in-containereg -COPY ./ ./will copy everything from current directory to container
docker build -t <dockerId>/<imageName> .egdocker build -t chetan/nodeApp .To run the tag imagedocker run chetan/nodeApp
docker run -p incomingPort : containerPort imageIdexampledocker run -p 8080 : 8080 chetan/nodeapp
docker run -it chetan/nodeapp
docker run -it chetan/nodeapp <command we need to run>egdocker run -it chetan/nodeapp sh
docker exec -it <containerId> <command we need to run>egdocker exec -it 21212121 sh
WORKDIR <folder>any command will run relative to this path in container egWORKDIR /user/app
docker ps
run
docker run -it -p 3000:3000 IMAGE_ID
Copy command creates a snapshot of the folders in the container, while volumes creates references.
run
docker run -p 3000:3000 -v /app/node_modules -v ${pwd}:/app <image_id>The above command says except node_module, reference everything inside container to the current directory.
To make networking between container easy.
docker-compose up
docker-compose up --build
to start
docker-compose up -dto stopdocker-compose down
add
stdin_open: true # docker run -iaddtty: true # docker run -t
volumes:
- /app/node_modules -> this says don't map node modules, use it from the container
- .:/app ---> this says map all content in current folder to conetnt under /app
get the Id of the running container, we started with docker-compose up to attach and run test run
docker exec -it <container-id> npm run testthis is make the test live reload on any changes