Questions tagged [containers]

A container is a class, a data structure, or an abstract data type whose instances are collections of other objects. Containers typically make use of generics or templates so that a wide variety of objects can be added.

Containers are available in most programming languages, allowing programmers to store, transfer, and read back data within a program. Common containers include arrays, lists, queues, stacks, sets, and maps, each providing different levels of efficiency for tasks such as adding or removing elements, searching for elements, or iterating through elements.

11206 questions
43
votes
3 answers

Why does storing references (not pointers) in containers in C++ not work?

In my program I have a STL set. set myStrings; To improve the efficiency of my code I changed it to hold, only pointers. (I don't need actual string copies to be stored.) set myStrings; I have read that it is a good practice to…
Julian Lettner
  • 3,309
  • 7
  • 32
  • 49
42
votes
2 answers

Iterating over a container of unique_ptr's

How does one access unique_ptr elements of a container (via an iterator) without taking ownership away from the container? When one gets an iterator to an element in the container is the element ownership still with the container? How about when one…
Dr DR
  • 667
  • 1
  • 5
  • 8
42
votes
3 answers

failed to start daemon: Error initializing network controller: Error creating default "bridge" network

I'm using Fedora release 33 (Thirty Three) Docker version is Docker version 20.10.0, build 7287ab3 First I ran docker system prune and since then docker daemon failed to start. I ran systemctl start docker command and got Job for docker.service…
Alon Barad
  • 1,491
  • 1
  • 13
  • 26
42
votes
5 answers

What is the difference between Docker Host and Container

I started learning about Docker. But I keep getting confused often, even though I read it in multiple places. Docker Host and Docker Container. Docker Engine is the base Engine that handles the containers. Docker Containers sit on top of Docker…
Kevin Rave
  • 13,876
  • 35
  • 109
  • 173
42
votes
3 answers

Template class with template container

How can I declare template class (adaptor) with different containers as template arguments? For example, I need to declare class: template class MyMultibyteString { Container buffer; ... }; And I want it to…
DuXeN0N
  • 1,577
  • 1
  • 14
  • 29
41
votes
7 answers

"multiset" & "multimap" - What's the point?

As the question states ... I don't get the point about multisets / multimaps. So, what's the purpose?
Sebastian
  • 8,046
  • 2
  • 34
  • 58
41
votes
15 answers

To STL or !STL, that is the question

Unquestionably, I would choose to use the STL for most C++ programming projects. The question was presented to me recently however, "Are there any cases where you wouldn't use the STL?"... The more I thought about it, the more I realized that…
dicroce
  • 45,396
  • 28
  • 101
  • 140
40
votes
6 answers

Get fragment's container view id

I have a fragment added using transaction.add(R.id.content, fragment, null); and I need to start new fragment from this one. But to do this I need to know first fragment's container view id (R.id.content in my case). How can I get this? I can just…
Dmitry Ryadnenko
  • 22,222
  • 4
  • 42
  • 56
40
votes
1 answer

Override env values defined in container spec

I have a configmap where I have defined the following key-value mapping in the data section: apiVersion: v1 kind: ConfigMap metadata: namespace: test name: test-config data: TEST: "CONFIGMAP_VALUE" then in the definition of my container (in…
asenovm
  • 6,397
  • 2
  • 41
  • 52
40
votes
6 answers

How to restore MySQL dump from host to Docker container

I'm sure this is a duplicated topic, but I simply cannot get it done: I like to restore my database dump to MySQL container in run time, without modifying the docker-compose.yml file. Dockerfile FROM php:5.4.45-apache RUN apt-get update RUN…
bimlas
  • 2,359
  • 1
  • 21
  • 29
40
votes
3 answers

Dockerfile and docker-compose not updating with new instructions

When I try to build a container using docker-compose like so nginx: build: ./nginx ports: - "5000:80" the COPY instructions isnt working when my Dockerfile simply looks like this FROM nginx #Expose port 80 EXPOSE 80 COPY html…
Leon
  • 5,701
  • 3
  • 38
  • 38
39
votes
2 answers

Shared library in containers

For two processes A and B, the both use the library libc.so, libc.so is loaded into memory only once. This is a normal situation when A and B both run on the same host and the same rootfs. When it comes to container, if A and B are running in…
Xinli Niu
  • 471
  • 1
  • 4
  • 6
38
votes
4 answers

Increase Disk Space on Docker Toolbox

I'm trying to start some very large Containers on Docker Toolbox (about 18 GB in total). Unfortunately, I always get the error that there is not enough disk space. I have a 1TB HDD and there are more than 200 GB free. How can I increase the disk…
Pascal
  • 2,590
  • 3
  • 21
  • 46
38
votes
1 answer

Docker alpine image's basic commands are not working

docker started to produce weird bugs when I was using a few simple alpine based containers. Two of these problems are: rc-update was not found when i was trying to use it after installing openssh package, there was nothing in /etc/ssh or there was…
SLOBY
  • 1,007
  • 2
  • 10
  • 24
38
votes
5 answers

Getting container/parent object from within python

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…
Michael McClenaghan
  • 639
  • 1
  • 5
  • 11