docker inspect -f "{{ .NetworkSettings }}" f20 docker build -t friendlyhello . # Create image using this directory's Dockerfile docker run -p 4000:80 friendlyhello # Run "friendlyhello" mapping port 4000 to 80 docker run -d -p 4000:80 friendlyhello # Same thing, but in detached mode docker container ls # List all running containers docker container ls -a # List all containers, even those not running docker container stop <hash> # Gracefully stop the specified container docker container kill <hash> # Force shutdown of the specified container docker container rm <hash> # Remove specified container from this machine docker container rm $(docker container ls -a -q) # Remove all containers docker image ls -a # List all images on this machine docker image rm <image id> # Remove specified image from this machine docker image rm $(docker image ls -a -q) # Remove all images from this machine docker login # Log in this CLI session using your Docker credentials docker tag <image> username/repository:tag # Tag <image> for upload to registry docker push username/repository:tag # Upload tagged image to registry docker run username/repository:tag # Run image from a registry
docker stop 'docker ps -q' #stop all the running containers
[fsevents] Success: "/Users/jackson/Downloads/frontend/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote
[fsevents] Success: "/Users/jackson/Downloads/frontend/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" already installed Pass --update-binary to reinstall or --build-from-source to recompile + react@16.8.3 + react-scripts@2.1.5 + react-dom@16.8.3 added 1948 packages from 733 contributors and audited 36230 packages in 147.639s found 63 low severity vulnerabilities run `npm audit fix` to fix them, or `npm audit` for details
Initialized a git repository.
Success! Created frontend at /Users/jackson/Downloads/frontend Inside that directory, you can run several commands:
npm start Starts the development server.
npm run build Bundles the app into static files for production.
npm test Starts the test runner.
npm run eject Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you can’t go back!
$ docker build -f Dockerfile.dev . Sending build context to Docker daemon 914.9kB Step 1/6 : FROM node:alpine ---> 4e50ad7c0e0b Step 2/6 : WORKDIR '/app' ---> Using cache ---> e99f36e2e99d Step 3/6 : COPY package.json . ---> Using cache ---> c5c9213cbf46 Step 4/6 : RUN npm install ---> Using cache ---> a770342ca69a Step 5/6 : COPY . . ---> 7c0e4f289ad5 Step 6/6 : CMD ["npm","run","start"] ---> Running in c9fd7f9cfbbe Removing intermediate container c9fd7f9cfbbe ---> 80bf791492c9 Successfully built 80bf791492c9
运行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
$ docker run -p 3000:3000 80bf791492c9
> frontend@0.1.0 start /app > react-scripts start
Starting the development server...
Compiled successfully!
You can now view frontend in the browser.
Local: http://localhost:3000/ On Your Network: http://172.17.0.2:3000/
Note that the development build is not optimized. To create a production build, use npm run build.
访问
打开浏览器访问localhost:3000即可访问react首页
1 2 3 4 5 6 7 8 9
If you are running on Windows, please read this: Create-React-App has some issues detecting when files get changed on Windows based machines. To fix this, please do the following:
In the root project directory, create a file called .env
Add the following text to the file and save it: CHOKIDAR_USEPOLLING=true
That's all!
For more on why this is required, you can check out: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-start-doesn-t-detect-changes