![]() Issue How do I publish a port associated with a service to a specific IP address or interface? For example, when publishing a port using the --publish syntax, the port is published to 0.0.0.0 instead of a specific interface's assigned IP address: $ docker service create --name web_app --replicas=2 --publish 22:22 example $ sudo netstat -an|grep LIST|grep 22 tcp 0 0 172.30.0.124:22 0.0.0.0:* Resolution There currently is no way to publish a port for a service and associate that published port to a specified IP address. At this time there's an existing feature request upstream within the moby repository, tracked via. This feature will be available in a future version of Docker Enterprise Edition. If you'd rather use Docker Toolbox than Docker for Mac then make sure you set the environment variables to talk to the right docker daemon: eval '$(docker-machine env default)' If you have time then have a look at Docker for Mac vs. Docker Toolbox in the online docs. On a Mac, Docker can be used even when connected to a very restrictive corporate VPN. Docker for Mac was architected from scratch to be able to fit the OS X sandbox security model and we are working closely with Apple to achieve this. See Docker for Mac and Docker for Windows in action in this video. 02 March 2018 1 comment tl;dr; Watch out for.dockerignore causing no such file or directory when building Docker images First I tried to use docker-compose: ▶ docker-compose build ui Building ui Step 1/8: FROM node:9 ---> 29831ba76d93 Step 2/8: ADD ui/package.json /package.json ERROR: Service 'ui' failed to build: ADD failed: stat /var/lib/docker/tmp/docker-builder079614651/ui/package.json: no such file or directory What the heck? Did I typo the name in the ui/Dockerfile? The docker-compose.yml directive for this was: yaml ui: build: context:. Dockerfile: ui/Dockerfile environment: - NODE_ENV=development ports: - '3000:3000' - '9' volumes: - $PWD/ui:/app command: start I don't know if it's the awesomest way to do docker-compose but I did copy this exactly from a different (working!) project. That other project called the web stuff frontend instead of ui in this project. The Dockerfile looked like this: FROM node:9 ADD./ui/package.json./ ADD./ui/package-lock.json./ RUN npm install EXPOSE 3000 EXPOSE 35729 CMD [ 'npm', 'start' ] Let's try without docker-compose. Or rather, do with docker what docker-compose does for me automatically. ▶ docker build ui -f ui/Dockerfile Sending build context to Docker daemon 158.2MB Step 1/8: FROM node:9 ---> 29831ba76d93 Step 2/8: ADD ui/package.json /package.json ADD failed: stat /var/lib/docker/tmp/docker-builder001494654/ui/package.json: no such file or directory So I thought I perhaps have misunderstood how relative paths worked. I tried EVERYTHING! I tried changing to docker build. Voice memos mac. The only workaround that I've found to convert Samsung memos from my Galaxy Fit to a text file or anything PC compatible was to do it from the smart phone itself. Numark mixtrack pro 2 driver for mac. -f ui/Dockerfile. I tried all sorts of combinations of this with also changing the line to ADD ui/package.json. Or ADD /ui/package.json. Or ADD./package.json. Or ADD package.json. Nothing worked. Finally I got it to work by doing ▶ cd ui ▶ docker build. -f Dockerfile but for that to work I had to remove all references of the directory name ui in the Dockerfile. Nice, but this is not going to work in docker-compose.yml since that starts outside the directory./ui/. So then I learned about contexts in docker. Well, I skimmed the docs rapidly. To keep things clean it's a good idea to do things within the directory that matters. So I made this change in the docker-compose.yml: ui: build: context: ui dockerfile: Dockerfile environment: - NODE_ENV=development ports: - '3000:3000' - '9' volumes: - $PWD/ui:/app command: start (Note the build.context: and build.dockerfile:) Still doesn't work! ? Still various variations of no such file or directory. The solution Turns out, in projectroot/.dockerignore it had ui/ as a line entry!!! I believe this project used to do some of the Python stuff with Docker and the React web app was done 'locally' on the host. And since the ui/node_modules directory is so huge someone decided it was smart of avoid Docker mounting that. Now the.dockerignore has.ui/node_modules and now everything works. I can build it with plain docker and docker-compose from outside the directory. Perhaps I should have spent the time I spent writing this blog post to instead file a structured GitHub issue on Docker itself somewhere. That it should have warned be better. 11 January 2018 0 comments,,, I have that is basically a React frontend, a Django API server and a Node universal React renderer. The killer feature is its Elasticsearch database that searches almost 2.5M large texts and 200K named objects. All the data is stored in a PostgreSQL and there's some Python code that copies that stuff over to Elasticsearch for indexing. The PostgreSQL database is about 10GB and the Elasticsearch (version 6.1.0) indices are about 6GB. It's moderately big and even though individual searches take, on average ~75ms (in production) it's hefty. At least for a side-project. On my MacBook Pro, laptop I use Docker to do development. Docker makes it really easy to run one command that starts memcached, Django, a AWS Product API Node app, create-react-app for the search and a separate create-react-app for the stats web app. At first I tried to also run PostgreSQL and Elasticsearch in Docker too, but after many attempts I had to just give up.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |