Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run imported image in Docker.io?

Tags:

node.js

docker

I have tried hello world node.js with docker. I have created an image & container. I exported the container using

docker export $container_ID > container_ID.tar

Q. How to run it after importing it back ?

docker import - <user-name>/node-hello < container_ID.tar
docker run -p 49610:8080 -d <user-name>/node-hello 

Error: create: No command specified


I found a a git hub issue import error

solution given here is :

docker run -p 49610:8080 -d <user-name>/node-hello /someCommandToRun.sh

I tried adding Dockerfile commands like (ADD ./src;cd ./src;npm install ; CMD['node','./src/index.js']) but the image fails with exit 127

Q. What is the command to give the node-hello-world image to run ?

like image 425
saurabh shashank Avatar asked Dec 15 '22 01:12

saurabh shashank


2 Answers

docker run takes a command to run as its final argument. The command must exist in the container. For example, docker run <image> bash will run bash in the container and then immediately exit. To have an interactive bash shell in the container use docker run -t -i <image> bash.

docker run does not take Dockerfile commands like ADD and CMD. To use a Dockerfile, put all your commands in a file called Dockerfile, then use docker build -t="some tag name" . to build the image.

You should begin with the Getting Started guide to better understand Docker.

like image 71
Ben Whaley Avatar answered Jan 05 '23 12:01

Ben Whaley


Q. How to run it after importing it back ?

Ans: docker run -p 49610:8080 -d <user-name>/node-hello /someCommandToRun.sh

Q. What is the command to give the node-hello-world image to run ?

Ans :docker run -p 49610:8080 -d <user-name>/node-hello node /src/index.js

like image 38
saurabh shashank Avatar answered Jan 05 '23 13:01

saurabh shashank