DEV Community

Zhangwuji
Zhangwuji

Posted on • Edited on

study docker

Image description

FROM node:16.20.2
COPY . /app
WORKDIR /app
RUN npm -v
RUN npm install
EXPOSE 8080
Enter fullscreen mode Exit fullscreen mode
docker build -t study:0.0.2 -f Dockfile.text .
Enter fullscreen mode Exit fullscreen mode

this command package the project as a image;

2.docker is server; you must start you can use docker;
open appication in windows

Image description
3.

docker save -o ko.jar study:0.0.2 
Enter fullscreen mode Exit fullscreen mode

will package image to a jar
4.

scp your_image_name.tar root@129.211.184.254:/path/to/destination

Enter fullscreen mode Exit fullscreen mode

link your server and push file to server
5.In server
you must install docker
you can use yum install

docker sudo apt-get install docker-ce depends on you systemOs;

6.

sudo systemctl enable docker

Enter fullscreen mode Exit fullscreen mode

it will automatically start docker after turn on the computer

7.

docker load -i /path/to/your_image_name.tar

Enter fullscreen mode Exit fullscreen mode

load image from local environment;

docker image ls;

docker run -it -p 8080:8080 --name test -d  -v /dd:/app study  
Enter fullscreen mode Exit fullscreen mode

-d is run the program in the background;
--name make a alias
-v map machine volume inside docker

Top comments (0)