containers

Can I change owner of directory that is mounted on volume in IBM containers?

前提是你 提交于 2019-11-28 01:05:55
I'm trying to launch postgres in IBM containers. I have just created volume by: $ cf ic volume create pgdata Then mount it: $ cf ic run --volume pgdata:/var/pgsql -p 22 registry.ng.bluemix.net/ruimo/pgsql944-cli After logging into container through ssh, I found the mounted directory is owned by root: drwxr-xr-x 3 root root 4096 Jul 8 08:20 pgsql Since postgres does not permit to run by root, I want to change the owner of this directory. But I cannot change the owner of this directory: # chown postgres:postgres pgsql chown: changing ownership of 'pgsql': Permission denied Is it possible to

How can I shift elements inside STL container

痴心易碎 提交于 2019-11-28 00:44:22
问题 I want to shift elements inside container on any positions to the left or right. The shifting elements are not contiguous. e.g I have a vector {1,2,3,4,5,6,7,8} and I want to shift {4,5,7} to the left on 2 positions, the expected result will be {1,4,5,2,7,3,6,8} Is there an elegant way to solve it ? 回答1: You can write your own shifting function. Here's a simple one: #include <iterator> #include <algorithm> template <typename Container, typename ValueType, typename Distance> void shift

How to set a specific fixed IP address when I create a docker machine or container?

自作多情 提交于 2019-11-28 00:37:08
问题 When I create my container, I want to set a specific container's IP address in the same LAN. Is that possible? If not, after the creation can I edit the DHCP IP address? 回答1: Considering the conclusion of the (now old October 2013) article "How to configure Docker to start containers on a specific IP address range", this doesn't seem to be possible (or at least "done automatically for you by Docker") yet . Update Nov 2015: a similar problem is discussed in docker/machine issue 1709, which

typedef and containers of const pointers

若如初见. 提交于 2019-11-28 00:27:46
问题 The following line of code compiles just fine and behaves: list<const int *> int_pointers; // (1) The following two lines do not: typedef int * IntPtr; list<const IntPtr> int_pointers; // (2) I get the exact same compile errors for list<int * const> int_pointers; // (3) I'm well aware that the last line is not legal since the elements of an STL container need to be assignable. Why is the compiler interpreting (2) to be the same as (3) ? 回答1: Short answer: is a list of pointers to constant

Docker container doesn't reload Angular app

纵然是瞬间 提交于 2019-11-27 23:38:39
I have some issue with ng serve in my docker container running by docker-compose . Dockerfile FROM node:7.1 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY package.json /usr/src/app RUN npm install RUN npm install -g angular-cli COPY . /usr/src/app EXPOSE 4200 CMD [ "npm", "start" ]' And my docker-compose.yml web: build: . ports: - '8089:4200' volumes: - .:/usr/src/app/ environment: - NODE_ENV=dev command: bash -c "npm start" Everything works great when I run it but the editing file does not rise reload of application. File is changed, I'm sure because I check it by ssh connection and the

Is there a sorted container in the STL?

社会主义新天地 提交于 2019-11-27 23:00:09
问题 Is there a sorted container in the STL? What I mean is following: I have an std::vector<Foo> , where Foo is a custom made class. I also have a comparator of some sort which will compare the fields of the class Foo . Now, somewhere in my code I am doing: std::sort( myvec.begin(), myvec.end(), comparator ); which will sort the vector according to the rules I defined in the comparator. Now I want to insert an element of class Foo into that vector. If I could, I would like to just write:

When do you prefer using std::list<T> instead of std::vector<T>?

99封情书 提交于 2019-11-27 21:07:02
I've never used std::list<T> myself. I was wondering when people use it when we already have std::vector<T> which is just like arrays with contiguous memory. std::vector seems like a perfect choice when we need sequential container! So my question is When exactly do you prefer std::list over std::vector ? and why exactly? When do you prefer std::vector over std::list ? and why? If there is performance consideration, then please list them too with detail explanation/information. If possible, quote some references also, to support your answer. Lists are better for inserting or deleting anywhere

Performance degradation due to default initialisation of elements in standard containers

China☆狼群 提交于 2019-11-27 20:28:26
(Yes, I know there is a question with almost the same title, but the answer was not satisfactory, see below) EDIT Sorry, the original question didn't use compiler optimization. This is now fixed, but to avoid trivial optimization and to come closer to my actual use case, the test has been split into two compilation units. The fact that the constructor of std::vector<> has linear complexity is a nuisance when it comes to performance-critical applications. Consider this simple code // compilation unit 1: void set_v0(type*x, size_t n) { for(size_t i=0; i<n; ++i) x[i] = simple_function(i); } //

How to access tomcat running in docker container from browser?

て烟熏妆下的殇ゞ 提交于 2019-11-27 20:06:33
I am running tomcat in my docker container from the Official Repo. docker pull tomcat And as per guidelines stated in the homepage I've run the instance and the Tomcat server is started docker run -it --rm -p 8888:8080 tomcat:8.0 And Tomcat server is available on the port 8888. I am able to get the response in the boot2docker when I execute the following command curl localhost:8888 But I would like to access the page from my web browser installed in my PC (which is out of the Virtual Box, the one that is installed in my Windows). Can I? If so how? You may be missing a port forwarding rule in

Getting container/parent object from within python

家住魔仙堡 提交于 2019-11-27 19:02:24
In Python, is it possible to get the object, say Foo, that contains another object, Bar, from within Bar itself? Here is an example of what I mean class Foo(object): def __init__(self): self.bar = Bar() self.text = "Hello World" class Bar(object): def __init__(self): self.newText = foo.text #This is what I want to do, #access the properties of the container object foo = Foo() Is this possible? Thanks! Pass a reference to the Bar object, like so: class Foo(object): def __init__(self): self.text = "Hello World" # has to be created first, so Bar.__init__ can reference it self.bar = Bar(self)